commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patri...@apache.org
Subject cvs commit: jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher LaunchTask.java ParentListener.java
Date Wed, 31 Jul 2002 01:20:10 GMT
patrickl    2002/07/30 18:20:09

  Modified:    daemon/src/java/org/apache/commons/launcher LaunchTask.java
                        ParentListener.java
  Log:
  Make Windows not hold on so tightly to the heartbeat file so that it will actually get deleted
after the parent or child JVM exits
  
  Revision  Changes    Path
  1.22      +8 -3      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask.java
  
  Index: LaunchTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- LaunchTask.java	24 Jul 2002 16:57:27 -0000	1.21
  +++ LaunchTask.java	31 Jul 2002 01:20:09 -0000	1.22
  @@ -582,16 +582,17 @@
               // ParentListener class on Windows since the entire child JVM
               // process will block on Windows machines using some versions of
               // Unix shells such as MKS, etc.
  +            File heartbeatFile = null;
  +            FileOutputStream heartbeatOutputStream = null;
               if (filteredWaitForChild) {
                   File tmpDir = null;
                   String tmpDirName = (String)sysProps.get("java.io.tmpdir");
                   if (tmpDirName != null)
                       tmpDir = new File(tmpDirName);
  -                File heartbeatFile = File.createTempFile(ChildMain.HEARTBEAT_FILE_PROP_NAME
+ ".", "", tmpDir);
  -                heartbeatFile.deleteOnExit();
  +                heartbeatFile = File.createTempFile(ChildMain.HEARTBEAT_FILE_PROP_NAME
+ ".", "", tmpDir);
                   // Open the heartbeat file for writing so that it the child JVM
                   // will not be able to delete it while this process is running
  -                FileOutputStream fos = new FileOutputStream(heartbeatFile);
  +                heartbeatOutputStream = new FileOutputStream(heartbeatFile);
                   sysProps.put(ChildMain.HEARTBEAT_FILE_PROP_NAME, heartbeatFile.getCanonicalPath());
               }
   
  @@ -696,6 +697,10 @@
                   // Let threads flush any unflushed output
                   stdout.join();
                   stderr.join();
  +                if (heartbeatOutputStream != null)
  +                    heartbeatOutputStream.close();
  +                if (heartbeatFile != null)
  +                    heartbeatFile.delete();
                   int exitValue = proc.exitValue();
                   if (filteredFailOnError && exitValue != 0)
                       throw new BuildException(Launcher.getLocalizedString("child.failed",
this.getClass().getName()) + " " + exitValue);
  
  
  
  1.3       +4 -3      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/ParentListener.java
  
  Index: ParentListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/ParentListener.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParentListener.java	19 Jul 2002 18:57:44 -0000	1.2
  +++ ParentListener.java	31 Jul 2002 01:20:09 -0000	1.3
  @@ -95,9 +95,6 @@
           heartbeatFile = new File(path);
           heartbeatFile.getCanonicalPath();
   
  -        // Clean up on exit
  -        heartbeatFile.deleteOnExit();
  -
       }
   
       //----------------------------------------------------------------- Methods
  @@ -172,6 +169,10 @@
               } catch (IOException ioe) {}
   
           }
  +
  +        // Clean up before exiting
  +        if (heartbeatFile != null)
  +            heartbeatFile.delete();
   
           // Exit this process since the parent JVM has exited
           System.exit(0);
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message