From owner-freebsd-questions Tue Jan 18 18: 4: 4 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mx2.x-treme.gr (mx2.x-treme.gr [212.120.192.15]) by hub.freebsd.org (Postfix) with ESMTP id 6E36414F49 for ; Tue, 18 Jan 2000 18:03:54 -0800 (PST) (envelope-from keramida@diogenis.ceid.upatras.gr) Received: from hades.hell.gr (pat44.x-treme.gr [212.120.197.236]) by mx2.x-treme.gr (8.9.3/8.9.3/IPNG-ADV-ANTISPAM-0.1) with ESMTP id DAA22457; Wed, 19 Jan 2000 03:58:53 +0200 Received: (from charon@localhost) by hades.hell.gr (8.9.3/8.9.3) id DAA58063; Wed, 19 Jan 2000 03:35:20 +0200 (EET) (envelope-from keramida@diogenis.ceid.upatras.gr) Date: Wed, 19 Jan 2000 03:35:20 +0200 From: Giorgos Keramidas To: Scott Hess Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Detecting when your parent process dies. Message-ID: <20000119033520.D57767@hades.hell.gr> Reply-To: keramida@ceid.upatras.gr References: <02f701bf610a$0c5fdec0$1e80000a@avantgo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3i In-Reply-To: <02f701bf610a$0c5fdec0$1e80000a@avantgo.com> X-PGP-Fingerprint: 62 45 D1 C9 26 F9 95 06 D6 21 2A C8 8C 16 C0 8E Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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: The kill() function sends the signal given by sig to pid, a process or a group of processes. Sig may be one of the signals specified in sigaction(2) or it may be 0, in which case error checking is performed but no signal is actually sent. This can be used to check the validity of pid. Therefore, what you need is: int is_parent_alive (void) { return (kill(getppid(), 0) == 0); } Not sure how this works with rfork() though... I haven't had the time to test it :/ -- Giorgos Keramidas, < keramida @ ceid . upatras . gr > "Don't let your schooling interfere with your education." [??] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message