Thread View: comp.unix.programmer
3 messages
3 total messages
Started by Todd Chauvin
Wed, 14 Nov 1990 18:05
How to guarantee the death of a child process
Author: Todd Chauvin
Date: Wed, 14 Nov 1990 18:05
Date: Wed, 14 Nov 1990 18:05
30 lines
1667 bytes
1667 bytes
Hello, I am working with a large simulation of a complicated communications network. The program is implemented as three separate processes. On startup: 1) parent creates three pipes 2) for each of the two child processes, parent does a vfork/exec, assigning input/output streams to the pipes created in (1) This simulation program is only useful if all three processes are running. The problem: How can I arrange the processes such that if any one of them dies for *any* reason, the remaining two will be killed. I've experimented with catching SIGCHLD in the parent process but with only limited success. The problems that I can't figure out how to solve with SIGCHLD are (1) figuring out which child generated the SIGCHLD (2) stopping SIGCHLD from being delivered to the parent when the parent process is stopped from the keyboard and put into background, and (3) SIGCHLD only detects the death of a child. If I kill the parent, how do the child processes know to die? Anyone have any ideas how this should be done? Any thoughts/advice appreciated! Todd Chauvin chauvin@galway.jpl.nasa.gov
Re: How to guarantee the death of a child process
Author: Scott M. Ballew
Date: Wed, 14 Nov 1990 21:09
Date: Wed, 14 Nov 1990 21:09
41 lines
2434 bytes
2434 bytes
In article <1990Nov14.180538.9896@elroy.jpl.nasa.gov> chauvin@galway.jpl.nasa.gov (Todd Chauvin) writes:
>I am working with a large simulation of a complicated communications network.
>The program is implemented as three separate processes.
>
>On startup: 1) parent creates three pipes
> 2) for each of the two child processes, parent does a
> vfork/exec, assigning input/output streams to
> the pipes created in (1)
>
>This simulation program is only useful if all three processes are running.
>
>The problem:
>
> How can I arrange the processes such that if any one of them dies
> for *any* reason, the remaining two will be killed.
Try the following:
On startup: 1) parent creates three pipes
2) parent creates three children with vfork/exec and
assigns the input and output to the pipes
3) parent executes a wait and waits for any of the
three to die then kills the other two
>I've experimented with catching SIGCHLD in the parent process but with only
>limited success. The problems that I can't figure out how to solve with
>SIGCHLD are (1) figuring out which child generated the SIGCHLD (2) stopping
>SIGCHLD from being delivered to the parent when the parent process is
>stopped from the keyboard and put into background, and (3) SIGCHLD only
>detects the death of a child. If I kill the parent, how do the child
>processes know to die?
Ok, if you use wait() instead of the signals, the pid of the dying
child is returned from wait (keep them around from the vfork() calls).
It is then a simple matter to kill the remaining two children. As for
killing the parent, have it catch SIGTERM (and/or others) and then have
it kill the three children (be sure to wait() for each to die so as to
avoid zombies).
Scott Ballew
Purdue University Department of Computer Sciences
Re: How to guarantee the death of a child process
Author: Dave Smythe
Date: Fri, 16 Nov 1990 08:11
Date: Fri, 16 Nov 1990 08:11
7 lines
706 bytes
706 bytes
Regarding killing the other siblings, could you not simply send SIGTERM, or somesuch to the process group? That would get them all... D -- Dave Smythe netcom!dsmythe@apple.com N6XLP (also dsmythe@portia.stanford.edu)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads