summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-01-12 12:22:38 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-01-12 12:22:38 +0000
commitf0c0277970f8283428b599d8da8089756583a26c (patch)
tree8aa0e3c16d050b4a4bbb4506cca5af1b1322cb8e /src
parentef92a14bfea7a16102b04711c9c18ad717e82ea1 (diff)
downloadguix-f0c0277970f8283428b599d8da8089756583a26c.tar.gz
* 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".

Diffstat (limited to 'src')
-rw-r--r--src/libmain/shared.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 0f7a89814b..d9cf9a8626 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