• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
test_sigwaitinfo()9 void test_sigwaitinfo() {
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     siginfo_t info;
20     int res = sigwaitinfo(&s, &info);
21     assert(!res);
22     // The following checks that sig is initialized.
23     assert(info.si_signo == SIGUSR1);
24     assert(-1 == __msan_test_shadow(&info, sizeof(info)));
25   }
26 }
27 
main(void)28 int main(void) {
29   test_sigwaitinfo();
30   return 0;
31 }
32