test/java/lang/ProcessBuilder/Basic.java
Print this page
@@ -2014,10 +2014,11 @@
try {
if (Unix.is()
&& new File("/bin/bash").exists()
&& new File("/bin/sleep").exists()) {
final String[] cmd = { "/bin/bash", "-c", "(/bin/sleep 6666)" };
+ final String[] cmdkill = { "/bin/bash", "-c", "(/usr/bin/pkill -f \"sleep 6666\")" };
final ProcessBuilder pb = new ProcessBuilder(cmd);
final Process p = pb.start();
final InputStream stdout = p.getInputStream();
final InputStream stderr = p.getErrorStream();
final OutputStream stdin = p.getOutputStream();
@@ -2041,10 +2042,11 @@
check(p.waitFor() != 0);
check(p.exitValue() != 0);
stdout.close();
stderr.close();
stdin.close();
+ new ProcessBuilder(cmdkill).start();
//----------------------------------------------------------
// There remain unsolved issues with asynchronous close.
// Here's a highly non-portable experiment to demonstrate:
//----------------------------------------------------------
if (Boolean.getBoolean("wakeupJeff!")) {