Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S263927AbUAaUKz (ORCPT ); Sat, 31 Jan 2004 15:10:55 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S264095AbUAaUKy (ORCPT ); Sat, 31 Jan 2004 15:10:54 -0500 Received: from disk.smurf.noris.de ([192.109.102.53]:52379 "EHLO server.smurf.noris.de") by vger.kernel.org with ESMTP id S263927AbUAaUKx (ORCPT ); Sat, 31 Jan 2004 15:10:53 -0500 From: "Matthias Urlichs" Date: Sat, 31 Jan 2004 21:00:50 +0100 To: Linus Torvalds Cc: Kernel Mailing List Subject: Re: BUG: NTPL: waitpid() doesn't return? Message-ID: <20040131200050.GA2160@kiste> References: <20040131104606.GA25534@kiste> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.5.1+cvs20040105i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1459 Lines: 40 Hi, Linus Torvalds: > > "Clearly" is not correct. What I bet happens is: > > > 31346 execve("/usr/bin/apt-ftparchive", ["apt-ftparchive", "packages", "testing/all"], [/* 12 vars */] > > 31346 <... execve resumed> ) = 0 > > 31346 exit_group(0) = ? > > 31340 --- SIGCHLD (Child exited) @ 0 (0) --- > > 31342 waitpid(31346, > > Notice how you do "waitpid()" for a _specific_ thread when you get a > SIGCHLD. > > How the heck do you know _which_ thread it was that exited? Please look again. The above trace clearly shows that #31346 has exited, which is exactly the thread being waitpid()ed for. What the program does is basically - spawn four threads or so - each thread forks off some process, and then waitpid()s for exactly that pid ... and all but the last waitpid() never returns even though all four child processes have exit_group()ed. > Rule: never EVER wait for a specific thread in a SIGCHLD handler. When you > get a SIGCHLD, your signal handler should just wait for "any thread". No SIGCHLD has been installed. (I checked the strace output.) -- Matthias Urlichs | noris network AG | http://smurf.noris.de/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/