Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2142291 | 6u2 | Martin Buchholz | P3 | Resolved | Fixed | b01 |
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 ----------
- backported by
-
JDK-2142291 (process) Runtime.exec() creates zombies (sol)
-
- Resolved
-
- duplicates
-
JDK-6587190 (process) ProcessBuilder creates defunct processes
-
- Closed
-
-
JDK-6594674 (process) Process.waitFor returns but process remains as zombie
-
- Closed
-
- relates to
-
JDK-4811767 (process) Runtime.exec should throw IOException when workdir does not exist (Unix)
-
- Resolved
-
-
JDK-6671051 (process) Runtime.exec() hangs if signalled during fork/exec
-
- Closed
-
-
JDK-4052517 (process) Runtime.exec won't execute programs belonging to other groups on Unix
-
- Resolved
-
-
JDK-5033302 (process) Can't execute Solaris NFS programs with uid>64k on Linux-amd64
-
- Resolved
-