8222000: JFR: Process start event

Reviewed-by: mgronlun, rriggs
This commit is contained in:
Erik Gahlin 2020-03-09 21:25:38 +01:00
parent 123ac07064
commit 672992f6ac
10 changed files with 207 additions and 7 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,8 @@ import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import jdk.internal.event.ProcessStartEvent;
import sun.security.action.GetPropertyAction;
/**
@ -1104,11 +1106,23 @@ public final class ProcessBuilder
}
try {
return ProcessImpl.start(cmdarray,
Process process = ProcessImpl.start(cmdarray,
environment,
dir,
redirects,
redirectErrorStream);
ProcessStartEvent event = new ProcessStartEvent();
if (event.isEnabled()) {
StringJoiner command = new StringJoiner(" ");
for (String s: cmdarray) {
command.add(s);
}
event.directory = dir;
event.command = command.toString();
event.pid = process.pid();
event.commit();
}
return process;
} catch (IOException | IllegalArgumentException e) {
String exceptionInfo = ": " + e.getMessage();
Throwable cause = e;