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

Ctrl-C in linux/sunOS is killing the foreground process and all of its children

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.4.1
    • hotspot
    • x86
    • linux

      This looks to be broken in 1.4.2-b19 build with latest CTRL+C changes. May be a regression.

      Name: nt126004 Date: 03/31/2003


      FULL PRODUCT VERSION :
      java version "1.4.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
      Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)


      FULL OS VERSION :
      Linux (SuSE 2.4.18-4GB)
      SunOS 5.9

      A DESCRIPTION OF THE PROBLEM :
      When executing a process with Runtime.getRuntime().exec() in a linux or solaris environment, if the parent process is running in foreground and you hit 'Ctr-C' both processes are terminated, although this doesn't happen if the father process is killed by sending any of SIGKILL, SIGINT or SIGTERM signals

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      -Compile and execute the attached code without any arguments
      -Check with ps that there are two processes
      -Send a kill -2 (SIGINT) to the parent process (the same can be tested with SIGKILL, SIGQUIT and SIGTERM)
      -Verify with ps that the child is still running (proper behaviour)
      -Kill the children process
      -Execute the father again
      -Verify both processes are created
      -Having the father process in foreground, hit Ctrl-C

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The child process should keep running
      Both processes are terminated

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;

      public class JDKProcessExecutionTest
      {

          public static void main(String[] args)
          {
              if (args.length > 1) {
                  //children
                  for(;;) {
                      System.out.println(" children! ");
                      try {
                          Thread.sleep(30 * 1000);
                      }
                      catch (InterruptedException e) {
                          //just ignore...
                      }
                  }
              }
              else {
                  //father

                  try {
                      Process p = Runtime.getRuntime().exec("java -cp . JDKProcessExecutionTest create child");

                      for(;;) {
                          System.out.println(" father! ");
                          try {
                              Thread.sleep(30 * 1000);
                          }
                          catch (InterruptedException e) {
                              //just ignore...
                          }
                      }
                  }
                  catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
      }
      ---------- END SOURCE ----------
      (Review ID: 182937)
      ======================================================================

            pcashman Pat Cashman
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: