Last change
on this file was 2036, checked in by bird, 20 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
709 bytes
|
Line | |
---|
1 | #include <signal.h>
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <stdlib.h>
|
---|
4 | #include <string.h>
|
---|
5 |
|
---|
6 | int win = 0;
|
---|
7 |
|
---|
8 | static void
|
---|
9 | handler (int sig)
|
---|
10 | {
|
---|
11 | printf ("Received signal %d (%s).\n", sig, strsignal(sig));
|
---|
12 | win = 1;
|
---|
13 | }
|
---|
14 |
|
---|
15 | int
|
---|
16 | main (void)
|
---|
17 | {
|
---|
18 | if (signal (SIGTERM, handler) == SIG_ERR)
|
---|
19 | {
|
---|
20 | perror ("signal: SIGTERM");
|
---|
21 | exit (EXIT_FAILURE);
|
---|
22 | }
|
---|
23 |
|
---|
24 | puts ("Set handler.");
|
---|
25 |
|
---|
26 | printf ("Sending myself signal %d.\n", SIGTERM);
|
---|
27 | fflush (stdout);
|
---|
28 |
|
---|
29 | if (raise (SIGTERM) < 0)
|
---|
30 | {
|
---|
31 | perror ("raise: SIGTERM");
|
---|
32 | exit (EXIT_FAILURE);
|
---|
33 | }
|
---|
34 |
|
---|
35 | if (!win)
|
---|
36 | {
|
---|
37 | puts ("Didn't get any signal. Test FAILED!");
|
---|
38 | exit (EXIT_FAILURE);
|
---|
39 | }
|
---|
40 |
|
---|
41 | puts ("Got a signal. Test succeeded.");
|
---|
42 |
|
---|
43 | return EXIT_SUCCESS;
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.