1 /* $NetBSD: fork.c,v 1.2 2003/04/11 12:56:25 lha Exp $ */
4 * Check that child process doesn't get threads, also make sure sleep
7 * Written by Love Hörnquist Åstrand <lha@NetBSD.org>, March 2003.
11 #include <sys/types.h>
22 static int thread_survived
= 0;
30 if (parent
!= getpid()) {
31 kill(parent
, SIGKILL
);
32 errx(1, "child thread running");
38 main(int argc
, char **argv
)
46 pthread_create(&p
, NULL
, print_pid
, NULL
);
50 err(1, "fork failed");
53 ret
= pthread_join(p
, NULL
);
54 if (ret
&& fork_pid
!= 0)
55 errx(1, "join failed in parent");
58 errx(1, "child_thread did NOT survive");
62 waitpid(fork_pid
, &status
, 0);
63 if (!WIFEXITED(status
) || WEXITSTATUS(status
) != 0)
64 errx(1, "child died wrongly");
69 if (thread_survived
) {
70 kill(parent
, SIGKILL
);
71 errx(1, "child_thread survived");