From bb07dfe96f0d07aa18db385d3ec93b24b5568213 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 23 Jul 2014 19:37:40 +0200 Subject: [PATCH] nix-daemon: Simplify stderr handling --- nix/libutil/util.cc | 1 + nix/nix-daemon/nix-daemon.cc | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 32244b2185..aa9d99ec33 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -850,6 +850,7 @@ pid_t startProcess(std::function fun, const string & errorPrefix) if (pid == -1) throw SysError("unable to fork"); if (pid == 0) { + _writeToStderr = defaultWriteToStderr; try { restoreAffinity(); fun(); diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index f2141ee536..ed3febd0af 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc @@ -48,7 +48,6 @@ static FdSource from(STDIN_FILENO); static FdSink to(STDOUT_FILENO); bool canSendStderr; -pid_t myPid; @@ -58,11 +57,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); @@ -663,7 +658,6 @@ static void performOp(bool trusted, unsigned int clientVersion, static void processConnection(bool trusted) { canSendStderr = false; - myPid = getpid(); _writeToStderr = tunnelStderr; #ifdef HAVE_HUP_NOTIFICATION