* sysdeps/unix/sysv/linux/openat.c (__atfct_seterrno): Use the same
[glibc.git] / signal / tst-signal.c
blob6d3178792a7e6b69ca19080d14a5116634f3a170
1 #include <signal.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 int win = 0;
8 static 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.");
43 return EXIT_SUCCESS;