Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4509995

Process.destroy() won't kill a STOPped process

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • None
    • 1.2.2
    • core-libs
    • sparc
    • solaris_8

    Description



      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)
      ======================================================================

      Attachments

        Activity

          People

            kkladkosunw Konstantin Kladko (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: