blob: b5f19b561e8663b06e6cb7be9d9e20f61a9d7ff8 [file] [log] [blame]
Dmitry V. Levin66a15a52014-01-07 19:32:32 +00001#include <assert.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <signal.h>
5
6static void handle_signal(int no)
7{
8 _exit(128 + no);
9}
10
11int
12main(void)
13{
Dmitry V. Levin38593e92014-02-26 16:51:28 +000014 struct sigaction sa, sa0;
Dmitry V. Levin66a15a52014-01-07 19:32:32 +000015
16 sa.sa_handler = SIG_IGN;
17 sigemptyset(&sa.sa_mask);
18 sigaddset(&sa.sa_mask, SIGHUP);
19 sigaddset(&sa.sa_mask, SIGINT);
20 sa.sa_flags = SA_RESTART;
Dmitry V. Levin38593e92014-02-26 16:51:28 +000021 assert(!sigaction(SIGUSR2, &sa, &sa0));
Dmitry V. Levin66a15a52014-01-07 19:32:32 +000022
23 sa.sa_handler = handle_signal;
24 sigemptyset(&sa.sa_mask);
25 sigaddset(&sa.sa_mask, SIGQUIT);
26 sigaddset(&sa.sa_mask, SIGTERM);
27 sa.sa_flags = SA_SIGINFO;
Dmitry V. Levin38593e92014-02-26 16:51:28 +000028 assert(!sigaction(SIGUSR2, &sa, &sa0));
Dmitry V. Levin66a15a52014-01-07 19:32:32 +000029
30 sa.sa_handler = SIG_DFL;
31 sigemptyset(&sa.sa_mask);
32 sa.sa_flags = 0;
Dmitry V. Levin38593e92014-02-26 16:51:28 +000033 assert(!sigaction(SIGUSR2, &sa, &sa0));
34
35 sigfillset(&sa.sa_mask);
36 sigdelset(&sa.sa_mask, SIGHUP);
37 assert(!sigaction(SIGUSR2, &sa, &sa0));
Dmitry V. Levin66a15a52014-01-07 19:32:32 +000038
39 return 0;
40}