10-29-2009, 04:11 AM
|
#2
|
Member
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811
Rep:
|
- Parent creates the three children, making note of their pids.
- Parent creates a pipe, and forks a fourth child having access to that pipe. The pipe is written to by the parent and read by the fourth child. So the parent should close the reading side of the pipe, and the child should close the writing side of the pipe.
- Over that pipe, the parent passes the pids of the first three children.
- The fourth child makes note of the three pids and waits for additional input on the pipe.
- The parent never makes additional output to that pipe.
- The parent eventually exits or dies. Example: someone sends it signal -9.
- The fourth child, waiting on input, sees end of file on the pipe.
- The fourth child then sends a signal to each of the first three children. USR1 is a good choice for the signal, or maybe HUP if you wish.
- Each of the first three children, upon receiving that signal, knows to clean up and exit.
Hope this helps.
|
|
1 members found this post helpful.
|