Name: mc57594 Date: 02/26/97
If you have multiple exec()s running, sometimes they return
each other's status. (This was frequent on 1.01 and 1.02 and
occasional on 1.1)
Here are the two shell files you need for the example
alwaysbad.sh
#! /bin/sh
exit 1
alwaysgood.sh
#! /bin/sh
exit 0
here is the java source that shows the bug
public class execbug
{
public static void main(String[] args) {
try {
for(int i=0; i < 1000; i++)
{
Runtime rt = Runtime.getRuntime();
String program1 = "alwaysgood.sh";
Process p1 = rt.exec(program1);
String program2 = "alwaysbad.sh";
Process p2 = rt.exec(program2);
if(p1.waitFor() != 0) {
System.out.println("alwaysgood returned bad on pass "
+ i);
}
if(p2.waitFor() != 1) {
System.out.println("alwaysbad returned good on pass "
+ i);
}
}
} catch(Exception e) {
System.out.println("exception " + e);
}
}
}
If you run this you should see one or two times that it prints
out "alwaysbad returned good" and some pass number
This is causing grief because I am trying to run several streams
of programs, and I need the exit status be the right one.
company - Storage Tek , email - ###@###.###
======================================================================
- duplicates
-
JDK-4040341 Process.waitfor () does not return correct value.
-
- Closed
-
-
JDK-4070278 the WaitFor method in the Process class give unexpected results
-
- Closed
-