diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-01-12T12·22+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-01-12T12·22+0000 |
commit | f0c0277970f8283428b599d8da8089756583a26c (patch) | |
tree | 8aa0e3c16d050b4a4bbb4506cca5af1b1322cb8e /src/libmain/shared.cc | |
parent | ef92a14bfea7a16102b04711c9c18ad717e82ea1 (diff) |
* 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/libmain/shared.cc')
-rw-r--r-- | src/libmain/shared.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 0f7a89814b6d..d9cf9a86262a 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 |