mirror of
https://github.com/NixOS/nix.git
synced 2025-11-12 05:26:02 +01:00
Fix interrupt handling
This commit is contained in:
parent
951357e5fb
commit
83ae6503e8
4 changed files with 41 additions and 13 deletions
|
|
@ -1197,18 +1197,22 @@ static void signalHandlerThread(sigset_t set)
|
|||
int signal = 0;
|
||||
sigwait(&set, &signal);
|
||||
|
||||
if (signal == SIGINT || signal == SIGTERM || signal == SIGHUP) {
|
||||
_isInterrupted = 1;
|
||||
if (signal == SIGINT || signal == SIGTERM || signal == SIGHUP)
|
||||
triggerInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto interruptCallbacks(_interruptCallbacks.lock());
|
||||
for (auto & callback : *interruptCallbacks) {
|
||||
try {
|
||||
callback();
|
||||
} catch (...) {
|
||||
ignoreException();
|
||||
}
|
||||
}
|
||||
void triggerInterrupt()
|
||||
{
|
||||
_isInterrupted = 1;
|
||||
|
||||
{
|
||||
auto interruptCallbacks(_interruptCallbacks.lock());
|
||||
for (auto & callback : *interruptCallbacks) {
|
||||
try {
|
||||
callback();
|
||||
} catch (...) {
|
||||
ignoreException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue