summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-event.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-23 21:44:20 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-23 21:44:20 +0100
commit3022d74ba585f961de7015087cd95673705bee3c (patch)
treee8525d9fe21337c2049ac8ebe77dee969c847401 /src/libsystemd-bus/sd-event.c
parentbe04cbca6c2c03e9f62e8981cb9b5626c118c953 (diff)
sd-event: make sd_event_add_signal() fail with EBUSY if signal is not blocked
Diffstat (limited to 'src/libsystemd-bus/sd-event.c')
-rw-r--r--src/libsystemd-bus/sd-event.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c
index 0317088af3..0b7b71d16e 100644
--- a/src/libsystemd-bus/sd-event.c
+++ b/src/libsystemd-bus/sd-event.c
@@ -22,6 +22,7 @@
#include <sys/epoll.h>
#include <sys/timerfd.h>
#include <sys/wait.h>
+#include <pthread.h>
#include "sd-id128.h"
#include "sd-daemon.h"
@@ -813,6 +814,7 @@ _public_ int sd_event_add_signal(
sd_event_source **ret) {
sd_event_source *s;
+ sigset_t ss;
int r;
assert_return(e, -EINVAL);
@@ -823,6 +825,13 @@ _public_ int sd_event_add_signal(
assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
assert_return(!event_pid_changed(e), -ECHILD);
+ r = pthread_sigmask(SIG_SETMASK, NULL, &ss);
+ if (r < 0)
+ return -errno;
+
+ if (!sigismember(&ss, sig))
+ return -EBUSY;
+
if (!e->signal_sources) {
e->signal_sources = new0(sd_event_source*, _NSIG);
if (!e->signal_sources)