1 // RUN: %clangxx -std=c++11 -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
3 // sigandset is glibc specific.
4 // UNSUPPORTED: android, target={{.*(freebsd|netbsd).*}}
14 sigset_t
mkset(int n
, ...) {
17 res
|= sigemptyset(&s
);
21 res
|= sigaddset(&s
, va_arg(va
, int));
28 sigset_t
sigset_or(sigset_t first
, sigset_t second
) {
30 int res
= sigorset(&out
, &first
, &second
);
35 sigset_t
sigset_and(sigset_t first
, sigset_t second
) {
37 int res
= sigandset(&out
, &first
, &second
);
42 int fork_and_signal(sigset_t s
) {
43 if (pid_t pid
= fork()) {
48 return !WIFEXITED(child_stat
);
51 int res
= sigwait(&s
, &sig
);
53 fprintf(stderr
, "died with sig %d\n", sig
);
59 // test sigorset... s should now contain SIGUSR1 | SIGUSR2
60 sigset_t s
= sigset_or(mkset(1, SIGUSR1
), mkset(1, SIGUSR2
));
61 sigprocmask(SIG_BLOCK
, &s
, 0);
63 res
= fork_and_signal(s
);
64 fprintf(stderr
, "fork_and_signal with SIGUSR1,2: %d\n", res
);
65 // CHECK: died with sig 10
66 // CHECK: fork_and_signal with SIGUSR1,2: 0
68 // test sigandset... s should only have SIGUSR2 now
69 s
= sigset_and(s
, mkset(1, SIGUSR2
));
70 res
= fork_and_signal(s
);
71 fprintf(stderr
, "fork_and_signal with SIGUSR2: %d\n", res
);
72 // CHECK: died with sig 12
73 // CHECK: fork_and_signal with SIGUSR2: 0