You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2013/08/01 02:39:30 UTC

git commit: Updated the launcher to redirect stderr/stdout during forked setup.

Updated Branches:
  refs/heads/master 75a8125a1 -> 2166dc2b7


Updated the launcher to redirect stderr/stdout during forked setup.

Review: https://reviews.apache.org/r/13177/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2166dc2b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2166dc2b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2166dc2b

Branch: refs/heads/master
Commit: 2166dc2b73e8e0dcd14cbceb86c91617ea2d992e
Parents: 75a8125
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Wed Jul 31 17:08:07 2013 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Jul 31 17:38:58 2013 -0700

----------------------------------------------------------------------
 src/launcher/launcher.cpp | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2166dc2b/src/launcher/launcher.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/launcher.cpp b/src/launcher/launcher.cpp
index c7d2c30..6226cd6 100644
--- a/src/launcher/launcher.cpp
+++ b/src/launcher/launcher.cpp
@@ -129,6 +129,20 @@ int ExecutorLauncher::setup()
     return -1;
   }
 
+  // Redirect output to files in working dir if required.
+  // TODO(bmahler): It would be best if instead of closing stderr /
+  // stdout and redirecting, we instead always output to stderr /
+  // stdout. Also tee'ing their output into the work directory files
+  // when redirection is desired.
+  if (redirectIO) {
+    if (freopen("stdout", "w", stdout) == NULL) {
+      fatalerror("freopen failed");
+    }
+    if (freopen("stderr", "w", stderr) == NULL) {
+      fatalerror("freopen failed");
+    }
+  }
+
   if (fetchExecutors() < 0) {
     cerr << "Failed to fetch executors" << endl;
     return -1;
@@ -155,16 +169,6 @@ int ExecutorLauncher::launch()
     switchUser();
   }
 
-  // Redirect output to files in working dir if required.
-  if (redirectIO) {
-    if (freopen("stdout", "w", stdout) == NULL) {
-      fatalerror("freopen failed");
-    }
-    if (freopen("stderr", "w", stderr) == NULL) {
-      fatalerror("freopen failed");
-    }
-  }
-
   setupEnvironment();
 
   const string& command = commandInfo.value();