|
Duplicate :
|
|
|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-beta2-b86, mixed mode)
A DESCRIPTION OF THE PROBLEM :
My application uses Runtime.exec() to execute external commands (shell scripts, system binaries).
If the external command does not exist an IOException is thrown and a defunct process (zombie) is left behind.
This issue does not appear in java version 1.5.0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
call Runtime.exec() with a non-existing file. e.g. 'Runtime.exec("no-such-file")'
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Checking the running processes does not show any defunct (zombie) process
ACTUAL -
After Runtime.exec runs, a defunct process is left behind, which is only removed when the JVM itself exits.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
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 {
Runtime.getRuntime().exec("no-such-file");
} catch (IOException e) { }
System.out.println("check after");
check();
}
}
---------- END SOURCE ----------
|