1 /* Check that exiting from a parent thread does not kill the child.
2 #notarget: cris*-*-elf
3 */
4 
5 #include <stddef.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <limits.h>
9 #include <unistd.h>
10 #include <sched.h>
11 #include <signal.h>
12 #include <errno.h>
13 #include <sys/types.h>
14 #include <sys/wait.h>
15 
16 int
process(void * arg)17 process (void *arg)
18 {
19   int i;
20 
21   for (i = 0; i < 50; i++)
22     if (sched_yield ())
23       abort ();
24 
25   printf ("pass\n");
26   return 0;
27 }
28 
29 int
main(void)30 main (void)
31 {
32   int pid;
33   long stack[16384];
34 
35   pid = clone (process, (char *) stack + sizeof (stack) - 64,
36 	       (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
37 	       | SIGCHLD, "ab");
38   if (pid <= 0)
39     {
40       fprintf (stderr, "Bad clone %d\n", pid);
41       abort ();
42     }
43 
44   exit (0);
45 }
46