diff options
Diffstat (limited to 'src/sighook.c')
-rw-r--r-- | src/sighook.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/sighook.c b/src/sighook.c index 820044c..fc0db6d 100644 --- a/src/sighook.c +++ b/src/sighook.c @@ -573,26 +573,32 @@ static int siginit(int sig) { return 0; } - struct sigsave *save = ALLOC(struct sigsave); - if (!save) { + sigset_t updated = signals; + if (sigaddset(&updated, sig) != 0) { return -1; } - save->sig = sig; - if (sigaction(sig, NULL, &save->action) != 0) { - free(save); + struct sigaction original; + if (sigaction(sig, NULL, &original) != 0) { return -1; } - rcu_list_append(&saved, &save->node); - if (sigaction(sig, &action, NULL) != 0) { + struct sigsave *save = ALLOC(struct sigsave); + if (!save) { return -1; } - if (sigaddset(&signals, sig) != 0) { + save->sig = sig; + save->action = original; + rcu_list_append(&saved, &save->node); + + if (sigaction(sig, &action, NULL) != 0) { + rcu_list_remove(&saved, &save->node); + free(save); return -1; } + signals = updated; return 0; } |