class Hang {
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
String cmd = "/bin/true";
while (true) {
System.out.println("Running " + cmd);
try {
Process p = r.exec(cmd);
int v = p.waitFor();
System.out.println(cmd + " returned " + v);
} catch (Exception e) {
System.err.println("Exception " + e);
}
}
}
}
Consider the above program. When I run it under Solaris with jdk.beta, I get:
Running /bin/true
pid 790 status 0
Received sigchild for 790 exit=0
/bin/true returned 0
Running /bin/true
The second Process.waitFor() never returns, even though the process does exit.
DREL 11/27/95
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
String cmd = "/bin/true";
while (true) {
System.out.println("Running " + cmd);
try {
Process p = r.exec(cmd);
int v = p.waitFor();
System.out.println(cmd + " returned " + v);
} catch (Exception e) {
System.err.println("Exception " + e);
}
}
}
}
Consider the above program. When I run it under Solaris with jdk.beta, I get:
Running /bin/true
pid 790 status 0
Received sigchild for 790 exit=0
/bin/true returned 0
Running /bin/true
The second Process.waitFor() never returns, even though the process does exit.
DREL 11/27/95
- relates to
-
JDK-1228933 exec() only works correctly the first time called
- Closed