On Tue, 13 Aug 2002, Angerstein wrote:

> I have a child and a parent process.
> Both should die if the other has ended.
> 

perldoc perlipc

Case 1) Child dies and parent still alive
In this case the signal SIGCHLD is sent to the parent.
You can set up a handler to SIGCHLD like this in your parent
$SIG{CHLD} = sub { die "Child process is dead" };

Case 2) Parent dies and child still alive
>From the parent you can send a signal to the child
and handle it in the child. Something like
Parent process
kill ('USR1', $child_pid);
Child process
$SIG{USR1} = sub { die "Parent process is dead" };

Usually in the case of forking you have a parent whose only
job is to fork and wait and the children do all the work.
In your case the parent forks two children and waits on both
of them (perldoc -f waitpid). When one of the children dies
it can kill the other and exit itself.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to