6 /* Test that signal masks are respected before threads are started */
7 volatile sig_atomic_t flag
;
9 void handler1(int sig
, siginfo_t
*info
, void *ctx
);
10 void handler2(int sig
, siginfo_t
*info
, void *ctx
);
13 handler1(int sig
, siginfo_t
*info
, void *ctx
)
16 kill(getpid(), SIGUSR2
);
18 * If the mask is properly set, SIGUSR2 will not be handled
19 * until this handler returns.
25 handler2(int sig
, siginfo_t
*info
, void *ctx
)
37 act
.sa_sigaction
= handler1
;
38 sigemptyset(&act
.sa_mask
);
39 sigaddset(&act
.sa_mask
, SIGUSR2
);
40 act
.sa_flags
= SA_SIGINFO
;
42 ret
= sigaction(SIGUSR1
, &act
, NULL
);
44 printf("sigaction: %d\n", ret
);
48 act
.sa_sigaction
= handler2
;
49 sigemptyset(&act
.sa_mask
);
50 act
.sa_flags
= SA_SIGINFO
;
51 ret
= sigaction(SIGUSR2
, &act
, NULL
);
53 kill(getpid(), SIGUSR1
);
56 printf("Success: Both handlers ran in order\n");
58 printf("Failure: flag was %d\n", (int)flag
);