From 0a89fae916a5a6ff5182ccfff2afb7dd7111afd3 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 19 May 2008 23:21:58 +0000 Subject: [PATCH] wait_for_child() does now wait for the main thread of a dead child to be gone. Fixes bug #1639. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25568 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/team.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index a0c1971803..7c3af957e1 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -1940,6 +1940,12 @@ wait_for_child(pid_t child, uint32 flags, int32 *_reason, atomic_and(&thread->sig_pending, ~SIGNAL_TO_MASK(SIGCHLD)); } + // When the team is dead, the main thread continues to live in the kernel + // team for a very short time. To avoid surprises for the caller we rather + // wait until the thread is really gone. + if (foundEntry.state == JOB_CONTROL_STATE_DEAD) + wait_for_thread(foundEntry.thread, NULL); + T(WaitForChildDone(foundEntry)); return foundEntry.thread;