OPERATING SYSTEM(S):
Linux ( and probably all Unix based JDKs )
FULL JDK VERSION(S):
java full version "1.5.0_06-b05"
DESCRIPTION:
The following testcase illustrates the problem.
ProcessTest.java
public class ProcessTest {
public static void main(String argv[]) {
try {
Process p = Runtime.getRuntime().exec("java Test");
p.waitFor();
System.out.println("exit = " + p.exitValue());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Test.java
public class Test
{
public static void main(String args[])
{
System.exit(-10);
}
}
On Windows one gets
java ProcessTest
exit = -10
On Linux one gets
java ProcessTest
exit = 246
This can be a problem on Unix if the WEXITSTATUS macro is not cast to a signed char before assigning to the return value.
Linux ( and probably all Unix based JDKs )
FULL JDK VERSION(S):
java full version "1.5.0_06-b05"
DESCRIPTION:
The following testcase illustrates the problem.
ProcessTest.java
public class ProcessTest {
public static void main(String argv[]) {
try {
Process p = Runtime.getRuntime().exec("java Test");
p.waitFor();
System.out.println("exit = " + p.exitValue());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Test.java
public class Test
{
public static void main(String args[])
{
System.exit(-10);
}
}
On Windows one gets
java ProcessTest
exit = -10
On Linux one gets
java ProcessTest
exit = 246
This can be a problem on Unix if the WEXITSTATUS macro is not cast to a signed char before assigning to the return value.