From 99655245ae21dd18403ce79f54199c13574da9aa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Dec 2006 17:21:42 +0000 Subject: * Use an explicit handler for SIGCHLD, since SIG_IGN doesn't do the right thing on FreeBSD 4 (it leaves zombies). --- src/nix-worker/main.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/nix-worker') diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc index 6a0dcc13d..4397697ba 100644 --- a/src/nix-worker/main.cc +++ b/src/nix-worker/main.cc @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include 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); -- cgit v1.2.3