diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-08-11 15:54:06 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-08-11 15:54:06 -0400 |
commit | c5168071738467fb67e932976e56f364291cca60 (patch) | |
tree | 54e3955cd2a4c5f4d5839ae2fafc251edc431b99 /src/time | |
parent | 140778582487fb082716eec74324d7b16beb2daf (diff) | |
download | musl-c5168071738467fb67e932976e56f364291cca60.tar.gz musl-c5168071738467fb67e932976e56f364291cca60.tar.bz2 musl-c5168071738467fb67e932976e56f364291cca60.tar.xz musl-c5168071738467fb67e932976e56f364291cca60.zip |
block signals in timer threads
if a timer thread leaves signals unblocked, any future attempt by the
main thread to prevent the process from being terminated by blocking
signals will fail, since the signal can still be delivered to the
timer thread.
Diffstat (limited to 'src/time')
-rw-r--r-- | src/time/timer_create.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/time/timer_create.c b/src/time/timer_create.c index 1561d797..593f73aa 100644 --- a/src/time/timer_create.c +++ b/src/time/timer_create.c @@ -80,6 +80,7 @@ int timer_create(clockid_t clk, struct sigevent *evp, timer_t *res) struct start_args args; struct ksigevent ksev, *ksevp=0; int timerid; + sigset_t set; switch (evp ? evp->sigev_notify : SIGEV_SIGNAL) { case SIGEV_NONE: @@ -104,7 +105,10 @@ int timer_create(clockid_t clk, struct sigevent *evp, timer_t *res) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_barrier_init(&args.b, 0, 2); args.sev = evp; + sigfillset(&set); + pthread_sigmask(SIG_BLOCK, &set, &set); r = pthread_create(&td, &attr, start, &args); + pthread_sigmask(SIG_SETMASK, &set, 0); if (r) { errno = r; return -1; |