Home | History | Annotate | Download | only in msan
      1 // RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t && %run %t
      2 
      3 #include <assert.h>
      4 #include <sanitizer/msan_interface.h>
      5 #include <signal.h>
      6 #include <sys/time.h>
      7 #include <unistd.h>
      8 
      9 void test_sigwait() {
     10   sigset_t s;
     11   sigemptyset(&s);
     12   sigaddset(&s, SIGUSR1);
     13   sigprocmask(SIG_BLOCK, &s, 0);
     14 
     15   if (pid_t pid = fork()) {
     16     kill(pid, SIGUSR1);
     17     _exit(0);
     18   } else {
     19     int sig;
     20     int res = sigwait(&s, &sig);
     21     assert(!res);
     22     // The following checks that sig is initialized.
     23     assert(sig == SIGUSR1);
     24   }
     25 }
     26 
     27 int main(void) {
     28   test_sigwait();
     29   return 0;
     30 }
     31