4 1. Signals should remain pending while blocked, and not delivered early
6 2. When unblocking the signal, the signal should have been delivered
7 by the time sigprocmask syscall is complete.
15 static volatile int gotsig
= 0;
16 static volatile int early
= 1;
18 static void handler(int sig
)
20 printf("4: got signal %s\n",
21 ( sig
== SIGUSR1
? "SIGUSR1" : "unexpected signal" ));
24 fprintf(stderr
, "FAILED: got signal %d instead\n", sig
);
29 fprintf(stderr
, "FAILED: signal delivered early (in handler)\n");
42 sigemptyset(&sigusr1
);
43 sigaddset(&sigusr1
, SIGUSR1
);
45 sigprocmask(SIG_BLOCK
, &all
, NULL
);
47 signal(SIGUSR1
, handler
);
48 signal(SIGHUP
, handler
);
50 printf("1: sending signal\n");
51 kill(getpid(), SIGUSR1
);
52 kill(getpid(), SIGHUP
);
54 printf("2: sleeping\n");
58 fprintf(stderr
, "FAILED: signal delivered too early\n");
62 printf("3: unblocking\n");
64 sigprocmask(SIG_UNBLOCK
, &sigusr1
, NULL
);
66 printf("5: unblocked...\n");
68 fprintf(stderr
, "FAILED: signal not delivered\n");
72 printf("6: checking SIGHUP still pending...\n");
76 if (sigwaitinfo(&all
, &info
) == -1) {
77 perror("FAILED: sigwaitinfo failed");
80 if (info
.si_signo
!= SIGHUP
) {
81 fprintf(stderr
, "FAILED: SIGHUP not still pending; got signal %d\n",