summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-27 06:19:28 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-27 06:19:28 +0100
commit2a987ee8c94ac29545e3c94d47b5d493daea0b5e (patch)
tree3df2034ff10ca14b4229bb0094b7e45e89d334c7 /util.c
parent47a71eed0f41c8661361d5506e47d1b223613680 (diff)
reset signal handlers on startup
Diffstat (limited to 'util.c')
-rw-r--r--util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/util.c b/util.c
index c7b2ca8516..4774610265 100644
--- a/util.c
+++ b/util.c
@@ -468,3 +468,25 @@ char *path_make_absolute(const char *p, const char *prefix) {
return r;
}
+
+int reset_all_signal_handlers(void) {
+ int sig;
+
+ for (sig = 1; sig < _NSIG; sig++) {
+ struct sigaction sa;
+
+ if (sig == SIGKILL || sig == SIGSTOP)
+ continue;
+
+ zero(sa);
+ sa.sa_handler = SIG_DFL;
+
+ /* On Linux the first two RT signals are reserved by
+ * glibc, and sigaction() will return EINVAL for them. */
+ if ((sigaction(sig, &sa, NULL) < 0))
+ if (errno != EINVAL)
+ return -errno;
+ }
+
+ return 0;
+}