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_sigwaitinfo() { |
10 | sigset_t s; |
11 | sigemptyset(set: &s); |
12 | sigaddset(set: &s, SIGUSR1); |
13 | sigprocmask(SIG_BLOCK, set: &s, oset: 0); |
14 | |
15 | if (pid_t pid = fork()) { |
16 | kill(pid: pid, SIGUSR1); |
17 | _exit(status: 0); |
18 | } else { |
19 | siginfo_t info; |
20 | int res = sigwaitinfo(set: &s, info: &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 | |
28 | int main(void) { |
29 | test_sigwaitinfo(); |
30 | return 0; |
31 | } |
32 |