Updated to fedora-glibc-20051003T2040
[glibc.git] / malloc / tst-mallocfork.c
blobabbc9d83b6bac238da5c916352bba9c3fea98c16
1 /* Derived from the test case in
2 http://sourceware.org/bugzilla/show_bug.cgi?id=838. */
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>
11 static void
12 sig_handler (int signum)
14 pid_t child = fork ();
15 if (child == 0)
16 exit (0);
17 TEMP_FAILURE_RETRY (waitpid (child, NULL, 0));
20 static int
21 do_test (void)
23 pid_t parent = getpid ();
25 struct sigaction action;
26 sigemptyset (&action.sa_mask);
27 action.sa_handler = sig_handler;
29 malloc (sizeof (int));
31 if (sigaction (SIGALRM, &action, NULL) != 0)
33 puts ("sigaction failed");
34 return 1;
37 /* Create a child that sends the signal to be caught. */
38 pid_t child = fork ();
39 if (child == 0)
41 if (kill (parent, SIGALRM) == -1)
42 perror ("kill");
43 exit (0);
46 TEMP_FAILURE_RETRY (waitpid (child, NULL, 0));
48 return 0;
51 #define TEST_FUNCTION do_test ()
52 #include "../test-skeleton.c"