x86/cet: Check CPU_FEATURE_ACTIVE in permissive mode
[glibc.git] / malloc / tst-mallocfork.c
blob00851a16c3f15a5f30be1bda42677dad3d3e3f4b
1 /* Derived from the test case in
2 https://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>
10 #include <libc-diag.h>
12 static void
13 sig_handler (int signum)
15 pid_t child = fork ();
16 if (child == 0)
17 exit (0);
18 TEMP_FAILURE_RETRY (waitpid (child, NULL, 0));
21 static int
22 do_test (void)
24 pid_t parent = getpid ();
26 struct sigaction action = { .sa_handler = sig_handler };
27 sigemptyset (&action.sa_mask);
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. */
33 malloc (sizeof (int));
34 DIAG_POP_NEEDS_COMMENT;
36 if (sigaction (SIGALRM, &action, NULL) != 0)
38 puts ("sigaction failed");
39 return 1;
42 /* Create a child that sends the signal to be caught. */
43 pid_t child = fork ();
44 if (child == 0)
46 if (kill (parent, SIGALRM) == -1)
47 perror ("kill");
48 exit (0);
51 TEMP_FAILURE_RETRY (waitpid (child, NULL, 0));
53 return 0;
56 #define TEST_FUNCTION do_test ()
57 #include "../test-skeleton.c"