Update.
[glibc.git] / signal / tst-signal.c
blob37e44a3a21377fb6410c81a6cf509cf1bf5a6fb9
1 #include <signal.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 int win = 0;
8 void
9 handler (int sig)
11 printf ("Received signal %d (%s).\n", sig, strsignal(sig));
12 win = 1;
15 int
16 main (void)
18 if (signal (SIGTERM, handler) == SIG_ERR)
20 perror ("signal: SIGTERM");
21 exit (EXIT_FAILURE);
24 puts ("Set handler.");
26 printf ("Sending myself signal %d.\n", SIGTERM);
27 fflush (stdout);
29 if (raise (SIGTERM) < 0)
31 perror ("raise: SIGTERM");
32 exit (EXIT_FAILURE);
35 if (!win)
37 puts ("Didn't get any signal. Test FAILED!");
38 exit (EXIT_FAILURE);
41 puts ("Got a signal. Test succeeded.");
42 exit (EXIT_SUCCESS);