xref: /aosp_15_r20/external/AFLplusplus/test/test-unsigaction.c (revision 08b48e0b10e97b33e7b60c5b6e2243bd915777f2)
1 #include <signal.h>          /* sigemptyset(), sigaction(), kill(), SIGUSR1 */
2 #include <stdlib.h>                                               /* exit() */
3 #include <unistd.h>                                             /* getpid() */
4 #include <errno.h>                                                 /* errno */
5 #include <stdio.h>                                             /* fprintf() */
6 
mysig_handler(int sig)7 static void mysig_handler(int sig) {
8 
9   exit(2);
10 
11 }
12 
main()13 int main() {
14 
15   /* setup sig handler */
16   struct sigaction sa;
17   sa.sa_handler = mysig_handler;
18   sigemptyset(&sa.sa_mask);
19   sa.sa_flags = 0;
20   if (sigaction(SIGCHLD, &sa, NULL)) {
21 
22     fprintf(stderr, "could not set signal handler %d, aborted\n", errno);
23     exit(1);
24 
25   }
26 
27   kill(getpid(), SIGCHLD);
28   return 0;
29 
30 }
31 
32