diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-05-22 01:46:08 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-05-22 01:46:08 +0200 |
commit | 9a34ec5fbb4b55413dc9d610b636fe760d34ecd7 (patch) | |
tree | 75ca3c00d0954ad3c78dbb1c616d6fafd2b93ff0 /src/util.c | |
parent | e1ce2c2782015579f042d4d6963ed039333fb8c2 (diff) |
execute: only reset those signals to the default we really need to reset to the default
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c index 5c1e16ab6e..47b1b443ff 100644 --- a/src/util.c +++ b/src/util.c @@ -1735,14 +1735,59 @@ int release_terminal(void) { return r; } -int ignore_signal(int sig) { +int sigaction_many(const struct sigaction *sa, ...) { + va_list ap; + int r = 0, sig; + + va_start(ap, sa); + while ((sig = va_arg(ap, int)) > 0) + if (sigaction(sig, sa, NULL) < 0) + r = -errno; + va_end(ap); + + return r; +} + +int ignore_signals(int sig, ...) { struct sigaction sa; + va_list ap; + int r = 0; zero(sa); sa.sa_handler = SIG_IGN; sa.sa_flags = SA_RESTART; - return sigaction(sig, &sa, NULL); + if (sigaction(sig, &sa, NULL) < 0) + r = -errno; + + va_start(ap, sig); + while ((sig = va_arg(ap, int)) > 0) + if (sigaction(sig, &sa, NULL) < 0) + r = -errno; + va_end(ap); + + return r; +} + +int default_signals(int sig, ...) { + struct sigaction sa; + va_list ap; + int r = 0; + + zero(sa); + sa.sa_handler = SIG_DFL; + sa.sa_flags = SA_RESTART; + + if (sigaction(sig, &sa, NULL) < 0) + r = -errno; + + va_start(ap, sig); + while ((sig = va_arg(ap, int)) > 0) + if (sigaction(sig, &sa, NULL) < 0) + r = -errno; + va_end(ap); + + return r; } int close_pipe(int p[]) { |