]>
Commit | Line | Data |
---|---|---|
7dac9f3d | 1 | /* Derived from the test case in |
a306c790 | 2 | https://sourceware.org/bugzilla/show_bug.cgi?id=838. */ |
7dac9f3d UD |
3 | #include <assert.h> |
4 | #include <errno.h> | |
5 | #include <stdio.h> | |
6 | #include <stdlib.h> | |
7 | #include <unistd.h> | |
8 | #include <sys/types.h> | |
9 | #include <sys/wait.h> | |
e6e24243 | 10 | #include <libc-diag.h> |
7dac9f3d UD |
11 | |
12 | static void | |
13 | sig_handler (int signum) | |
14 | { | |
15 | pid_t child = fork (); | |
16 | if (child == 0) | |
17 | exit (0); | |
18 | TEMP_FAILURE_RETRY (waitpid (child, NULL, 0)); | |
19 | } | |
20 | ||
21 | static int | |
22 | do_test (void) | |
23 | { | |
24 | pid_t parent = getpid (); | |
25 | ||
bd7b22b2 | 26 | struct sigaction action = { .sa_handler = sig_handler }; |
7dac9f3d | 27 | sigemptyset (&action.sa_mask); |
7dac9f3d | 28 | |
e6e24243 JM |
29 | DIAG_PUSH_NEEDS_COMMENT; |
30 | DIAG_IGNORE_NEEDS_COMMENT (10, "-Wunused-result"); | |
31 | /* The result of malloc is deliberately ignored, so do not warn | |
32 | about that. */ | |
7dac9f3d | 33 | malloc (sizeof (int)); |
e6e24243 | 34 | DIAG_POP_NEEDS_COMMENT; |
7dac9f3d UD |
35 | |
36 | if (sigaction (SIGALRM, &action, NULL) != 0) | |
37 | { | |
38 | puts ("sigaction failed"); | |
39 | return 1; | |
40 | } | |
41 | ||
42 | /* Create a child that sends the signal to be caught. */ | |
43 | pid_t child = fork (); | |
44 | if (child == 0) | |
45 | { | |
46 | if (kill (parent, SIGALRM) == -1) | |
47 | perror ("kill"); | |
48 | exit (0); | |
49 | } | |
50 | ||
51 | TEMP_FAILURE_RETRY (waitpid (child, NULL, 0)); | |
52 | ||
53 | return 0; | |
54 | } | |
55 | ||
56 | #define TEST_FUNCTION do_test () | |
57 | #include "../test-skeleton.c" |