Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jan 2000 07:05:01 -0800
From:      "Scott Hess" <scott@avantgo.com>
To:        <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Detecting when your parent process dies.
Message-ID:  <044601bf628e$8f5650e0$1e80000a@avantgo.com>
References:  <200001190922.KAA01178@dorifer.heim3.tu-clausthal.de>

next in thread | previous in thread | raw e-mail | index | archive | help
"Oliver Fromme" <olli@dorifer.heim3.tu-clausthal.de> wrote:
> Scott Hess <scott@avantgo.com> wrote in list.freebsd-questions:
>  > "Giorgos Keramidas" <charon@hades.hell.gr> wrote:
>  >> On Mon, Jan 17, 2000 at 08:43:57AM -0800, Scott Hess wrote:
>  >> | Is there any way for an rfork() process to detect if it's parent
process
>  >> | has died?  I mean via some sort of asynchronous notification?
>  >>
>  >> From the manpage of kill(2) we read:
>  >
>  > kill( pid, 0) tells me, if I know to ask, "Is this process alive."
>  > Unfortunately, the process I want to know that is going to be in a
read(),
>  > or perhaps a select().  I could arrange for it to poll for the parent
>  > process death, but that's going to be fairly inefficient.
>
> You're right, that would be inefficient and "ugly".
>
> There is a better way:  You can arrange to open a pipe() or
> socketpair() between the parent and the child process, and
> include the file descriptor in your select() FD set (the one
> checking for reading).

I may not have been complete enough in my description.  I'm using rfork()
_without_ RFFDG or RFCFDG.  This means that the parent and child share file
descriptor tables.  That means that the above fix won't work, because even
if the parent process exits, the pipe will still be open on both ends (as
long as one or more children live), so you'll never detect EOF.

I suspect that this also means that most file descriptor based tricks won't
work, because of the shared file descriptor table.

Later,
scott




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?044601bf628e$8f5650e0$1e80000a>