You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/08 23:30:10 UTC

[07/12] incubator-slider git commit: SLIDER-201 closing process input stream on fork

SLIDER-201 closing process input stream on fork


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/b6a3b541
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/b6a3b541
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/b6a3b541

Branch: refs/heads/releases/slider-0.60
Commit: b6a3b541ea5ae7d402fb3b90a6aa0245c44b3b34
Parents: 5d25442
Author: Steve Loughran <st...@apache.org>
Authored: Fri Nov 7 17:24:02 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Sat Nov 8 21:53:38 2014 +0000

----------------------------------------------------------------------
 .../apache/slider/server/services/workflow/LongLivedProcess.java | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/b6a3b541/slider-core/src/main/java/org/apache/slider/server/services/workflow/LongLivedProcess.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/workflow/LongLivedProcess.java b/slider-core/src/main/java/org/apache/slider/server/services/workflow/LongLivedProcess.java
index 57b989c..cebb035 100644
--- a/slider-core/src/main/java/org/apache/slider/server/services/workflow/LongLivedProcess.java
+++ b/slider-core/src/main/java/org/apache/slider/server/services/workflow/LongLivedProcess.java
@@ -51,6 +51,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
  * Key Features:
  * <ol>
  *   <li>Output is streamed to the output logger provided</li>.
+ *   <li>the input stream is closed as soon as the process starts.</li>
  *   <li>The most recent lines of output are saved to a linked list</li>.
  *   <li>A synchronous callback, {@link LongLivedProcessLifecycleEvent}, is raised on the start
  *   and finish of a process.</li>
@@ -323,6 +324,8 @@ public class LongLivedProcess implements Runnable {
       lifecycleCallback.onProcessStarted(this);
     }
     try {
+      //close stdin for the process
+      IOUtils.closeStream(process.getOutputStream());
       exitCode = process.waitFor();
     } catch (InterruptedException e) {
       LOG.debug("Process wait interrupted -exiting thread", e);
@@ -416,6 +419,7 @@ public class LongLivedProcess implements Runnable {
     }
     return getRecentOutput();
   }
+
   /**
    * add the recent line to the list of recent lines; deleting
    * an earlier on if the limit is reached.