< prev index next >
src/java.base/share/classes/java/lang/ProcessBuilder.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2003, 2017, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 32,41 ****
--- 32,43 ----
import java.io.OutputStream;
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;
/**
* This class is used to create operating system processes.
*
*** 1102,1116 ****
throw new IOException("invalid null character in command");
}
}
try {
! return ProcessImpl.start(cmdarray,
environment,
dir,
redirects,
redirectErrorStream);
} catch (IOException | IllegalArgumentException e) {
String exceptionInfo = ": " + e.getMessage();
Throwable cause = e;
if ((e instanceof IOException) && security != null) {
// Can not disclose the fail reason for read-protected files.
--- 1104,1130 ----
throw new IOException("invalid null character in command");
}
}
try {
! 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;
if ((e instanceof IOException) && security != null) {
// Can not disclose the fail reason for read-protected files.
< prev index next >