1 /* Check resulting signal mask from POSIX timer using SIGEV_THREAD.
2 Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
24 #include <support/check.h>
25 #include <support/test-driver.h>
26 #include <support/xthread.h>
28 #include <internal-signals.h>
30 static pthread_barrier_t barrier
;
33 thread_handler (union sigval sv
)
36 sigprocmask (SIG_BLOCK
, NULL
, &ss
);
38 printf ("%s: blocked signal mask = { ", __func__
);
39 for (int sig
= 1; sig
< NSIG
; sig
++)
41 /* POSIX timers threads created to handle SIGEV_THREAD block all
42 signals except SIGKILL, SIGSTOP and glibc internals ones. */
43 if (sigismember (&ss
, sig
))
45 TEST_VERIFY (sig
!= SIGKILL
&& sig
!= SIGSTOP
);
46 TEST_VERIFY (!__is_internal_signal (sig
));
48 if (test_verbose
&& sigismember (&ss
, sig
))
54 xpthread_barrier_wait (&barrier
);
60 struct sigevent sev
= { 0 };
61 sev
.sigev_notify
= SIGEV_THREAD
;
62 sev
.sigev_notify_function
= &thread_handler
;
65 TEST_COMPARE (timer_create (CLOCK_REALTIME
, &sev
, &timerid
), 0);
67 xpthread_barrier_init (&barrier
, NULL
, 2);
69 struct itimerspec trigger
= { 0 };
70 trigger
.it_value
.tv_nsec
= 1000000;
71 TEST_COMPARE (timer_settime (timerid
, 0, &trigger
, NULL
), 0);
73 xpthread_barrier_wait (&barrier
);
78 #include <support/test-driver.c>