sd-event: make sd_event_add_signal() fail with EBUSY if signal is not blocked

This commit is contained in:
Lennart Poettering 2013-12-23 21:44:20 +01:00
parent be04cbca6c
commit 3022d74ba5
1 changed files with 9 additions and 0 deletions

View File

@ -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)