Mon Jun 3 21:03:54 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / signal / tst-signal.c
blobf622842f7a5d132d2fa8f6006416ec9e2e3bd31e
1 #include <ansidecl.h>
2 #include <signal.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 int win = 0;
9 void
10 DEFUN(handler, (sig), int sig)
12 printf("Received signal %d (%s).\n", sig, strsignal(sig));
13 win = 1;
16 int
17 DEFUN_VOID(main)
19 if (signal(SIGTERM, handler) == SIG_ERR)
21 perror("signal: SIGTERM");
22 exit(EXIT_FAILURE);
25 puts("Set handler.");
27 printf("Sending myself signal %d.\n", SIGTERM);
28 fflush(stdout);
30 if (raise(SIGTERM) < 0)
32 perror("raise: SIGTERM");
33 exit(EXIT_FAILURE);
36 if (!win)
38 puts("Didn't get any signal. Test FAILED!");
39 exit(EXIT_FAILURE);
42 puts("Got a signal. Test succeeded.");
43 exit(EXIT_SUCCESS);