about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-23T17·37+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-23T17·37+0200
commitd0fad1779f85d4d356d658e99458734e9ab5809a (patch)
treea343f5685b7251090d76c7a5584c85f91ec34566
parent78224cd871e7ce9af628836995620abcb70e6935 (diff)
nix-daemon: Simplify stderr handling
-rw-r--r--src/libutil/util.cc1
-rw-r--r--src/nix-daemon/nix-daemon.cc8
2 files changed, 2 insertions, 7 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 32244b2185b6..aa9d99ec3353 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -850,6 +850,7 @@ pid_t startProcess(std::function<void()> fun, const string & errorPrefix)
     if (pid == -1) throw SysError("unable to fork");
 
     if (pid == 0) {
+        _writeToStderr = defaultWriteToStderr;
         try {
             restoreAffinity();
             fun();
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 250d03653e7e..83d9207351ba 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -29,7 +29,6 @@ static FdSource from(STDIN_FILENO);
 static FdSink to(STDOUT_FILENO);
 
 bool canSendStderr;
-pid_t myPid;
 
 
 /* This function is called anytime we want to write something to
@@ -38,11 +37,7 @@ pid_t myPid;
    socket. */
 static void tunnelStderr(const unsigned char * buf, size_t count)
 {
-    /* Don't send the message to the client if we're a child of the
-       process handling the connection.  Otherwise we could screw up
-       the protocol.  It's up to the parent to redirect stderr and
-       send it to the client somehow (e.g., as in build.cc). */
-    if (canSendStderr && myPid == getpid()) {
+    if (canSendStderr) {
         try {
             writeInt(STDERR_NEXT, to);
             writeString(buf, count, to);
@@ -533,7 +528,6 @@ static void processConnection(bool trusted)
     MonitorFdHup monitor(from.fd);
 
     canSendStderr = false;
-    myPid = getpid();
     _writeToStderr = tunnelStderr;
 
     /* Exchange the greeting. */