1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
3 // Always enable asserts.
14 static bool signal_handler_ran
= false;
16 void do_nothing_signal_handler(int signum
) {
17 write(1, "HANDLER\n", 8);
18 signal_handler_ran
= true;
22 const int kSignalToTest
= SIGSYS
;
23 assert(SIG_ERR
!= signal(kSignalToTest
, do_nothing_signal_handler
));
25 assert(0 == sigemptyset(&empty_set
));
26 sigset_t one_signal
= empty_set
;
27 assert(0 == sigaddset(&one_signal
, kSignalToTest
));
29 assert(0 == sigprocmask(SIG_BLOCK
, &one_signal
, &old_set
));
31 assert(!signal_handler_ran
);
33 assert(0 == sigfillset(&all_but_one
));
34 assert(0 == sigdelset(&all_but_one
, kSignalToTest
));
35 sigsuspend(&all_but_one
);
36 assert(signal_handler_ran
);
38 // Restore the original set.
39 assert(0 == sigprocmask(SIG_SETMASK
, &old_set
, NULL
));