Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jan 2000 08:43:57 -0800
From:      "Scott Hess" <scott@avantgo.com>
To:        <freebsd-questions@freebsd.org>
Subject:   Detecting when your parent process dies.
Message-ID:  <02f701bf610a$0c5fdec0$1e80000a@avantgo.com>

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

I can detect death of a child process via SIGCHLD and wait()/wait4().

I can detect death of a fork()ed parent by opening a pipe before the fork,
and having the child detect when the pipe gets closed.  Unfortunately, I'm
using rfork() such that file descriptors are shared, so the OS won't close
the parent's file descriptors on premature termination.

The best idea I've come up with thus far is to spin a manager process which
creates the current parent process as a child, and then let that process
watch for SIGCHLD.  This seems a bit extreme (not to mention confusing,
because it means that the "real" pid of the process isn't the first one of
ten, it's the second one of ten...).

Ideas?

Thanks,
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?02f701bf610a$0c5fdec0$1e80000a>