about summary refs log tree commit diff
path: root/src/nix-worker/main.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-05T17·21+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-05T17·21+0000
commit99655245ae21dd18403ce79f54199c13574da9aa (patch)
treef356d3f503b6ec49626a47c903baeeed9fdbde46 /src/nix-worker/main.cc
parent62b0497c0f2e1b269c7284684524d20c39c1d519 (diff)
* Use an explicit handler for SIGCHLD, since SIG_IGN doesn't do the
  right thing on FreeBSD 4 (it leaves zombies).

Diffstat (limited to 'src/nix-worker/main.cc')
-rw-r--r--src/nix-worker/main.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc
index 6a0dcc13d56c..4397697bab2f 100644
--- a/src/nix-worker/main.cc
+++ b/src/nix-worker/main.cc
@@ -10,10 +10,12 @@
 #include <unistd.h>
 #include <signal.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <fcntl.h>
+#include <errno.h>
 
 using namespace nix;
 
@@ -403,10 +405,17 @@ static void processConnection()
 }
 
 
-static void setSigChldAction(bool ignore)
+static void sigChldHandler(int sigNo)
+{
+    /* Reap all dead children. */
+    while (waitpid(-1, 0, WNOHANG) == 0) ;
+}
+
+
+static void setSigChldAction(bool autoReap)
 {
     struct sigaction act, oact;
-    act.sa_handler = ignore ? SIG_IGN : SIG_DFL;
+    act.sa_handler = autoReap ? sigChldHandler : SIG_DFL;
     sigfillset(&act.sa_mask);
     act.sa_flags = 0;
     if (sigaction(SIGCHLD, &act, &oact))
@@ -463,7 +472,10 @@ static void daemonLoop()
                 (struct sockaddr *) &remoteAddr, &remoteAddrLen);
             checkInterrupt();
             if (remote == -1)
-                throw SysError("accepting connection");
+		if (errno == EINTR)
+		    continue;
+		else
+		    throw SysError("accepting connection");
 
             printMsg(lvlInfo, format("accepted connection %1%") % remote);