9 #ifndef TEST_CLONE_FLAGS
10 #define TEST_CLONE_FLAGS 0
20 sival
.sival_int
= getpid ();
21 printf ("pid = %d\n", sival
.sival_int
);
22 if (sigqueue (getppid (), sig
, sival
) != 0)
31 int mypid
= getpid ();
37 if (sigprocmask (SIG_BLOCK
, &ss
, NULL
) != 0)
39 printf ("sigprocmask failed: %m\n");
44 extern int __clone2 (int (*__fn
) (void *__arg
), void *__child_stack_base
,
45 size_t __child_stack_size
, int __flags
,
47 char st
[256 * 1024] __attribute__ ((aligned
));
48 pid_t p
= __clone2 (f
, st
, sizeof (st
), TEST_CLONE_FLAGS
, 0);
50 char st
[128 * 1024] __attribute__ ((aligned
));
51 pid_t p
= clone (f
, st
+ sizeof (st
), TEST_CLONE_FLAGS
, 0);
55 printf("clone failed: %m\n");
58 printf ("new thread: %d\n", (int) p
);
62 if (sigwaitinfo (&ss
, &si
) < 0)
64 printf("sigwaitinfo failed: %m\n");
68 while (si
.si_signo
!= sig
|| si
.si_code
!= SI_QUEUE
);
71 if (waitpid (p
, &e
, __WCLONE
) != p
)
73 puts ("waitpid failed");
80 printf ("died from signal %s\n", strsignal (WTERMSIG (e
)));
82 puts ("did not terminate correctly");
85 if (WEXITSTATUS (e
) != 0)
87 printf ("exit code %d\n", WEXITSTATUS (e
));
91 if (si
.si_int
!= (int) p
)
93 printf ("expected PID %d, got si_int %d\n", (int) p
, si
.si_int
);
100 printf ("expected PID %d, got si_pid %d\n", (int) p
, (int) si
.si_pid
);
105 if (getpid () != mypid
)
107 puts ("my PID changed");
114 #define TEST_FUNCTION do_test ()
115 #include "../test-skeleton.c"