Name: bsT130419 Date: 10/02/2001
java version "1.2.2"
Solaris VM (build Solaris_JDK_1.2.2_05, native threads, sunwjit)
If a subprocess is started and a SIGSTOP is sent to it, then a subsequent
Process.destroy() call will fail to kill the process (although a ``kill -TERM''
will).
Interesting note: if the process is sent a SIGSTOP and then a SIGCONT, the
Process.destroy() call will also fail. (That is, if the subprocess
*ever* gets a SIGSTOP, it seems to stop the Process.destroy() from
succeeding). Unless one sends their own SIGTERM after the SIGCONT.
Anyway, here is the code (copied from the bug I mentioned initially), except
for some comment changes.
import java.io.*;
public class Foo {
public static void main(String args[])
{
try
{
Process foo = Runtime.getRuntime().exec("java Bar");
System.out.println("Started Bar");
// Wait 10 seconds
// at this point, suspend this process
// and send some of the signals mentioned
// in the bugreport to the ``Bar'' subprocess
Thread.currentThread().sleep(10000);
// try to kill the process
System.out.println("Killing runjava");
foo.destroy(); // doesn't work
// get exit value -- will throw exception if process not killed!
foo.exitValue();
}
catch (InterruptedException e) {System.out.println(e.getMessage());}
catch (IOException e) {System.out.println(e.getMessage());}
catch (IllegalThreadStateException e) {System.out.println(e.getMessage());}
}
}
public class Bar {
public static void main(String args[])
{
// Just sit here.
Object foo = new Object();
synchronized (foo) {
try {
foo.wait();
} catch (InterruptedException e) {}
}
}
}
(Review ID: 132325)
======================================================================