Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jan 2000 03:35:20 +0200
From:      Giorgos Keramidas <charon@hades.hell.gr>
To:        Scott Hess <scott@avantgo.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Detecting when your parent process dies.
Message-ID:  <20000119033520.D57767@hades.hell.gr>
In-Reply-To: <02f701bf610a$0c5fdec0$1e80000a@avantgo.com>
References:  <02f701bf610a$0c5fdec0$1e80000a@avantgo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000119033520.D57767>