FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux <hostname> 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 athlon i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The ProcessBuilder constructor was called using a syntax ("command param-1 param-2") instead of ("command","param-1","param-2").
When ProcessBuilder fails to find the command to be executed (perhaps due to a argument parsing change in Java 1.6.0), a defunct/zombie process is created that can be seen in the output of a "ps -ef" command on Linux.
This problem is not reproducable in Java 1.5.0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Call ProcessBuilder() constructor with the syntax ("command param-1 param-2") instead of passing the parameters as separate arguments to the constructor.
2. Try to execute the "command" with the ProcessBuilder.start() method
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Checking the running processes does not show any defunct/zombie process.
ACTUAL -
After ProcessBuilder.start() runs, a defunct process is left behind for each invokation.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
---------- BEGIN SOURCE ----------
import java.lang.*;
public class Zombie{
private static void check() {
try {
Process p = Runtime.getRuntime().exec("ps -ef");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true) {
line = br.readLine();
if (line == null)
break;
if (line.indexOf("defunct") > 0) {
System.out.println(line);
}
}
} catch (IOException e) { }
}
public static void main(String[] args) {
System.out.println("check before");
check();
try {
ProcessBuilder pb = new ProcessBuilder("nothing-to-run param1 param2");
Process proc = pb.start();
} catch (IOException e) { }
System.out.println("check after");
check();
}
}
---------- END SOURCE ----------
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
ProcessBuilder constructor should not be called with parameters and command together
Release Regression From : 5.0
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.