From owner-freebsd-questions Wed Jan 19 7: 6: 8 2000 Delivered-To: freebsd-questions@freebsd.org Received: from bomber.avantgo.com (ws1.avantgo.com [207.214.200.194]) by hub.freebsd.org (Postfix) with ESMTP id 0EFBF14C49 for ; Wed, 19 Jan 2000 07:06:06 -0800 (PST) (envelope-from scott@avantgo.com) Received: from river ([10.0.128.30]) by bomber.avantgo.com (Netscape Messaging Server 3.5) with SMTP id 347 for ; Wed, 19 Jan 2000 07:02:27 -0800 Message-ID: <044601bf628e$8f5650e0$1e80000a@avantgo.com> From: "Scott Hess" To: References: <200001190922.KAA01178@dorifer.heim3.tu-clausthal.de> Subject: Re: Detecting when your parent process dies. Date: Wed, 19 Jan 2000 07:05:01 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "Oliver Fromme" wrote: > Scott Hess wrote in list.freebsd-questions: > > "Giorgos Keramidas" 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