On Wed, Nov 19, 2008 at 12:16 PM, Jonathan Steel <[EMAIL PROTECTED]> wrote:
> In the SIGCHLD signal handler of parent process, I need to get the pid of
> the child when the child dies. To do this I'm using sigaction with the
> SA_SIGINFO flag. But the siginfo_t->si_pid member does not seem to be set.
>
> I found the following post from Otto that seems to say that what I'm trying
> to do may not work on OpenBSD.
>
> http://www.archivum.info/fa.openbsd.tech/2008-02/msg00124.html

> Does anybody know how I'm to accomplish this, or why it doesn't work?

I think the only way to go is to use wait() to get the child.

>From one of the links:
"The SA_NOCLDSTOP flag, when supplied in the act-> sa_flags parameter,
allows overloading SIGCHLD with the System V semantics that each
SIGCLD signal indicates a single terminated child. Most conforming
applications that catch SIGCHLD are expected to install
signal-catching functions that repeatedly call the waitpid() function
with the WNOHANG flag set, acting on each child for which status is
returned, until waitpid() returns zero. If stopped children are not of
interest, the use of the SA_NOCLDSTOP flag can prevent the overhead
from invoking the signal-catching routine when they stop."

Even if the pid were filled in, it would be a lot more work for the
kernel to reliably shoot a single for every process that died, so you
would have to loop on wait() anyway to cover the case where two
children die before you act.

Reply via email to