From f0c0277970f8283428b599d8da8089756583a26c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 12 Jan 2010 12:22:38 +0000 Subject: [PATCH] * On startup, set the default SIGCHLD handler. This is so that Nix works correctly in weird environments where the SIGCHLD handler is set to "ignore". --- src/libmain/shared.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 0f7a89814..d9cf9a862 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -143,23 +143,29 @@ static void initAndRun(int argc, char * * argv) maxSilentTime = queryIntSetting("build-max-silent-time", 0); /* Catch SIGINT. */ - struct sigaction act, oact; + struct sigaction act; act.sa_handler = sigintHandler; sigfillset(&act.sa_mask); act.sa_flags = 0; - if (sigaction(SIGINT, &act, &oact)) + if (sigaction(SIGINT, &act, 0)) throw SysError("installing handler for SIGINT"); - if (sigaction(SIGTERM, &act, &oact)) + if (sigaction(SIGTERM, &act, 0)) throw SysError("installing handler for SIGTERM"); - if (sigaction(SIGHUP, &act, &oact)) + if (sigaction(SIGHUP, &act, 0)) throw SysError("installing handler for SIGHUP"); /* Ignore SIGPIPE. */ act.sa_handler = SIG_IGN; act.sa_flags = 0; - if (sigaction(SIGPIPE, &act, &oact)) + if (sigaction(SIGPIPE, &act, 0)) throw SysError("ignoring SIGPIPE"); + /* Reset SIGCHLD to its default. */ + act.sa_handler = SIG_DFL; + act.sa_flags = 0; + if (sigaction(SIGCHLD, &act, 0)) + throw SysError("resetting SIGCHLD"); + /* There is no privacy in the Nix system ;-) At least not for now. In particular, store objects should be readable by everybody. This prevents nasty surprises when using a shared