Date: Fri, 20 Jul 2007 22:01:44 -0600 (MDT) From: Warner Losh <imp@bsdimp.com> To: ioplex@gmail.com Cc: freebsd-hackers@freebsd.org Subject: Re: Get pid of child that has exited? Message-ID: <20070720.220144.74739925.imp@bsdimp.com> In-Reply-To: <78c6bd860707201923x5d94d609s8715ce58282d865@mail.gmail.com> References: <78c6bd860707201923x5d94d609s8715ce58282d865@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070720.220144.74739925.imp>