From owner-freebsd-hackers@FreeBSD.ORG Sat Jul 21 04:04:24 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87AF216A418 for ; Sat, 21 Jul 2007 04:04:24 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 4BF2213C494 for ; Sat, 21 Jul 2007 04:04:23 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.13.8/8.13.4) with ESMTP id l6L41imq010264; Fri, 20 Jul 2007 22:01:44 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Fri, 20 Jul 2007 22:01:44 -0600 (MDT) Message-Id: <20070720.220144.74739925.imp@bsdimp.com> To: ioplex@gmail.com From: Warner Losh In-Reply-To: <78c6bd860707201923x5d94d609s8715ce58282d865@mail.gmail.com> References: <78c6bd860707201923x5d94d609s8715ce58282d865@mail.gmail.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Fri, 20 Jul 2007 22:01:44 -0600 (MDT) Cc: freebsd-hackers@freebsd.org Subject: Re: Get pid of child that has exited? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2007 04:04:24 -0000 > How does one get the pid if a child process that has exited? On other > systems this is available in siginfo_t but si_pid seems to be 0. Is > that normal? wait4, wait3 and waitpid will all return it: If wait4(), wait3(), or waitpid() returns due to a stopped, continued, or terminated child process, the process ID of the child is returned to the calling process. If there are no children not previously awaited, -1 is returned with errno set to ECHILD. Otherwise, if WNOHANG is specified and there are no stopped, continued or exited children, 0 is returned. If an error is detected or a caught signal aborts the call, a value of -1 is returned and errno is set to indicate the error. I don't know if si_pid == 0 is normal. I rarely use SIGCHILD to get the status of a child process. Warner