Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2039297 | 1.4.0 | Hui Huang | P3 | Closed | Fixed | beta |
Name: boT120536 Date: 12/13/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
I discovered this bug while running the JUnit test suite's sample tests
(http://www.junit.org/).
One of the tests in the suite runs a java VM in a separate process, but passes
it a "main" class which does not exist. The calling code then traps the
exit status code of the process and does an assertion check to confirm that
the exit status of the VM was -1. On linux, the exit status is erroneously
reported as 255, and the assertion fails.
public void testError() throws Exception {
execTest("junit.tests.BogusDude", -1);
}
void execTest(String testClass, int expected) throws Exception {
String java=
System.getProperty("java.home")+File.separator+"bin"+File.separator+"java";
String cp= System.getProperty("java.class.path");
String [] cmd= { java, "-cp", cp, "junit.textui.TestRunner",
testClass};
Process p= Runtime.getRuntime().exec(cmd);
InputStream i= p.getInputStream();
int b;
while((b= i.read()) != -1)
; //System.out.write(b);
int rc= p.waitFor();
assertEquals(expected, rc);
}
This reports an assertion error: expected -1, but got 255.
A member of the JUnit list offered the following explanation:
"This is a bug in the JVM implementation.
So, I don?t know about Red Hat, but with Blackdown, getting 255
instead of -1 is a missing cast in the JVM.
In a JVM file (UNIXProcess.c??), the offend line
probably reads:
exit_val = WEXITSTATUS(status);
it should read
exit_val = (signed char)WEXITSTATUS(status)
or something like that.
Complain to the JVM implementor."
(Review ID: 113722)
======================================================================
- backported by
-
JDK-2039297 Process.waitFor returns incorrect exit status code on linux
-
- Closed
-
- relates to
-
JDK-4379779 Linux: Process.exitValue() returns different value
-
- Closed
-
-
JDK-4459019 JDI spec: Wrong exit code returned after VirtualMachine.exit() on Linux
-
- Closed
-
-
JDK-4680945 Linux: System.exit(value) doesn't return the correct value to Process.waitFor()
-
- Closed
-