diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-01-17T17·21+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-01-17T17·21+0100 |
commit | cc3b93c991e04aff49a44dbced53f070a06f426e (patch) | |
tree | bc88ad9093faabd477ce935aedb5bd6a09459107 /src/libmain | |
parent | c0d55f918379f46b87e43457745895439a85555c (diff) |
Handle SIGINT etc. via a sigwait() signal handler thread
This allows other threads to install callbacks that run in a regular, non-signal context. In particular, we can use this to signal the downloader thread to quit. Closes #1183.
Diffstat (limited to 'src/libmain')
-rw-r--r-- | src/libmain/shared.cc | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 0c6e3fb76d64..44579a236774 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -24,12 +24,6 @@ namespace nix { -static void sigintHandler(int signo) -{ - _isInterrupted = 1; -} - - static bool gcWarning = true; void printGCWarning() @@ -120,19 +114,11 @@ void initNix() settings.processEnvironment(); settings.loadConfFile(); - /* Catch SIGINT. */ - struct sigaction act; - act.sa_handler = sigintHandler; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sigaction(SIGINT, &act, 0)) - throw SysError("installing handler for SIGINT"); - if (sigaction(SIGTERM, &act, 0)) - throw SysError("installing handler for SIGTERM"); - if (sigaction(SIGHUP, &act, 0)) - throw SysError("installing handler for SIGHUP"); + startSignalHandlerThread(); /* Ignore SIGPIPE. */ + struct sigaction act; + sigemptyset(&act.sa_mask); act.sa_handler = SIG_IGN; act.sa_flags = 0; if (sigaction(SIGPIPE, &act, 0)) |