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

(process) Control-C does not end forked Java process (w2k, wnt)

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      Name: gm110360 Date: 07/19/2002


      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 OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      ADDITIONAL OPERATING SYSTEMS :
      Microsoft Windows NT


      A DESCRIPTION OF THE PROBLEM :
      When indirectly (e.g., through Ant) starting a Java process
      in the original Windows console (DOS prompt) or in a third-
      party console such as Cygwin, only the directly started
      process can be killed by pressing Control-C.

      That is, as can be seen in the Windows Task Manager, the
      indirectly started process still runs and can therefore not
      be restarted if it listens to a specific socket, or delete
      (at start-up time) a temporary file it created, ...

      Now this behaviour ("child" process being fully independent
      of "parent" process") may be desired. The real problem is
      that sometimes, when trying to End [the Java] Process in
      the Task Manager, an "infinite" number of Java processes
      are started so that the computer gets clogged and a
      hardware reset is needed!


      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. run ControlCProblemDemo a couple of times (kill it with
      Control-C between runs) and note how the example file can
      always be deleted
      2. now run ExecuteControlCProblemDemo a couple of times
      (kill it with Control-C between runs) and note how the
      example file can no longer be deleted
      3. consult the Task Manager to see that there are still
      Java processes running
      4. try to kill these processes with End Process


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      In Java 1.3 killing a "parent" process also kills
      the "child" process. In Java 1.4 this is not the case.

      When killing a Java process in the Task Manager it should
      not go beserk by forking an infinite number of Java
      processes.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public
      class ExecuteControlCProblemDemo
      {
          public
          static
          void
          main( String[] args )
          {
              try {
                  Runtime.getRuntime().exec( "java ControlCProblemDemo" );
                  while ( true );
              } catch( IOException ioe ) {
                  System.err.println( ioe );
              }
          }
      }


      import java.io.File;
      import java.io.FileWriter;
      import java.io.IOException;

      public
      class ControlCProblemDemo
      {
          public
          static
          void
          main( String[] args )
          {
              File file = new File( "controlCProblemDemo" );
              if ( file.exists() ) {
                  System.out.println( "deleted controlCProblemDemo=" + file.delete
      () );
              }
              (new Thread( new ControlCProblemRunnable( file ) )).run();
              while ( true );
          }


          private
          static
          class ControlCProblemRunnable
              implements Runnable
          {
              private File file;


              public
              ControlCProblemRunnable( File file )
              {
                  this.file = file;
              }


              public
              void
              run()
              {
                  try {
                      FileWriter fileWriter = new FileWriter( file );
                      fileWriter.write( "Control-C Problem Demo" );
                      fileWriter.flush();
                      while ( true );
                  } catch( IOException ioe ) {
                      System.err.println( ioe );
                  }
              }
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      Log out of Windows and then log in again instead of trying
      to End [the Java] Process through the Task Manager.
      (Review ID: 158533)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                gmanwanisunw Girish Manwani (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: