[ILUG] Process alive?
mel at csn.ul.ie
Tue Nov 16 12:04:48 GMT 1999
On Mon, 15 Nov 1999, Justin Mason wrote:
> Caolan McNamara said:
> > On 15-Nov-99 Mel wrote:
> > > So I want the child
> > >to keep an eye on it's parent. If the parent dies, the child kills
> > >itself. Any insights on how this should be done properably?
> > Without looking at the code to see a better way, you could always stick
> > an atexit function into the "parent" which will send a signal to the
> Open a pipe(). That way you'll get a SIGPIPE or a close when the other
> process exits, whether or not you're the parent.
> I agree with Caolan though, atexit() is a good way to do it for the
> generic case; I'd only get mucky with pipes if you are really paranoid
> about the parent coredumping and leaving an orphaned child around.
Pipe wouldnt' work in this case because the child is executed with
system(). If I didn't use system, I would be using execl because I need a
totally seperate process, a copy with fork doesn't work. Can I use a pipe
with that sort of setup? I think atexit() (new function to me) might do
the job but at the moment, it's causing segfaults. I have a feeling it's
because the quit function is part of a library which is loaded at runtime.
By program termination, the library has been unloaded with my quit
function along with it (no, I can't compile the quit function into the
main part of the program). What does work, is trapping SIGUSR1 in the
parent and periodically getting the child to send SIGUSR1. If it fails, it
dies. God, the architecture for this program is beginning to irritate me.
More information about the ILUG