summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/TEST
diff options
context:
space:
mode:
authord <d@openbsd.org>1999-06-15 00:07:39 +0000
committerd <d@openbsd.org>1999-06-15 00:07:39 +0000
commita9cea9a366db5a2ad219f685426547e80c67470c (patch)
tree4c8ace29dfe8121d6d9cab9d05a69698ac5d6665 /lib/libc_r/TEST
parentmention the process' pid in the debug message. greatly helps to debug problems when fork()ing (diff)
downloadwireguard-openbsd-a9cea9a366db5a2ad219f685426547e80c67470c.tar.xz
wireguard-openbsd-a9cea9a366db5a2ad219f685426547e80c67470c.zip
Remove pthread_atfork(). It was only part of draft 10 for a little while and was removed before stddization.
Diffstat (limited to 'lib/libc_r/TEST')
-rw-r--r--lib/libc_r/TEST/test_fork.c60
1 files changed, 3 insertions, 57 deletions
diff --git a/lib/libc_r/TEST/test_fork.c b/lib/libc_r/TEST/test_fork.c
index bf0cc583c80..ab53ec41d4c 100644
--- a/lib/libc_r/TEST/test_fork.c
+++ b/lib/libc_r/TEST/test_fork.c
@@ -47,51 +47,6 @@ sigchld(sig)
SUCCEED;
}
-static int atfork_state = 0;
-
-void
-atfork_child2()
-{
- ASSERT(atfork_state++ == 3);
- ASSERT(getpid() != parent_pid);
-}
-
-void
-atfork_parent2()
-{
- ASSERT(atfork_state++ == 3);
- ASSERT(getpid() == parent_pid);
-}
-
-void
-atfork_prepare2()
-{
- ASSERT(atfork_state++ == 0);
- ASSERT(getpid() == parent_pid);
-}
-
-
-void
-atfork_child1()
-{
- ASSERT(atfork_state++ == 2);
- ASSERT(getpid() != parent_pid);
-}
-
-void
-atfork_parent1()
-{
- ASSERT(atfork_state++ == 2);
- ASSERT(getpid() == parent_pid);
-}
-
-void
-atfork_prepare1()
-{
- ASSERT(atfork_state++ == 1);
- ASSERT(getpid() == parent_pid);
-}
-
int
main()
{
@@ -112,36 +67,27 @@ main()
CHECKe(signal(SIGCHLD, sigchld));
- /* Install some atfork handlers */
-
- CHECKr(pthread_atfork(&atfork_prepare1, &atfork_parent1,
- &atfork_child1));
- CHECKr(pthread_atfork(&atfork_prepare2, &atfork_parent2,
- &atfork_child2));
-
- printf("forking\n");
+ printf("forking from pid %d\n", getpid());
CHECKe(pid = fork());
switch(pid) {
case 0:
/* child: */
+ printf("child = pid %d\n", getpid());
/* Our pid should change */
ASSERT(getpid() != parent_pid);
/* Our sleeper thread should have disappeared */
ASSERT(ESRCH == pthread_cancel(sleeper_thread));
- /* The atfork handler should have run */
- ASSERT(atfork_state++ == 4);
printf("child ok\n");
_exit(0);
PANIC("child _exit");
default:
/* parent: */
+ printf("parent = pid %d\n", getpid());
/* Our pid should stay the same */
ASSERT(getpid() == parent_pid);
/* Our sleeper thread should still be around */
CHECKr(pthread_cancel(sleeper_thread));
- /* The atfork handler should have run */
- ASSERT(atfork_state++ == 4);
/* wait for the SIGCHLD from the child */
CHECKe(pause());
PANIC("pause");