[opensuse] SOT: signaling grandchildren processes
I have a program that starts and stops a child process w/ STOP and CONT signals. Is there a way to do the same for any processes the child forks (i.e. grandchild, great grandchild, etc.)? TIA, Jeffrey -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tue, 2008-01-22 at 11:33 -0600, Jeffrey L. Taylor wrote:
I have a program that starts and stops a child process w/ STOP and CONT signals. Is there a way to do the same for any processes the child forks (i.e. grandchild, great grandchild, etc.)?
There is the concept of a process group. Maybe setpgrp/getpgrp will give a clue? All children, and their children, are part of the same process group. I think this is really coarse grained in that you can do things to all members of the process group, not just specific ones. But maybe you can use this to find who they are. Sorry I cannot say more. I have not really used this. -- Roger Oberholtzer OPQ Systems / Ramböll RST Ramböll Sverige AB Kapellgränd 7 P.O. Box 4205 SE-102 65 Stockholm, Sweden Office: Int +46 8-615 60 20 Mobile: Int +46 70-815 1696 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Roger Oberholtzer wrote:
On Tue, 2008-01-22 at 11:33 -0600, Jeffrey L. Taylor wrote:
I have a program that starts and stops a child process w/ STOP and CONT signals. Is there a way to do the same for any processes the child forks (i.e. grandchild, great grandchild, etc.)?
Yes. original process opens a socket before forking any children, and pass the socket ID to the child process in the argument vector. When the main process forks off a child, it immediately has the PID of the child process, because the fork(2) returns the PID of the child process to the parent. With this, the parent process can start to build a tree (with itself as root, and all child processes as first-level nodes). Likewise, Child processes (and grand children, etc), all know the PID of offspring of the next generation, and if each one ALSO has the socket number of the original process, each one can report new offspring to the original process as soon as fork(2) returns. If strict "geneology" is required, each reporting process should send a 2-tuple message consisting of its own PID, and the child process which it just forked off. (or n-tuple if additional identifying data is required). With this information, the parent process can construct a tree of all "offspring" processes. Likewise, calling wait(2), using WNOHANG, each generation of processes can monitor the continued existance of its children, and report the death of any child process (say, by reporting a dead child as a negative number, i.e. -PID) similar to reporting a newly forked child. Note that this method requires programming in C, C++, or a similar language capable of calling fork(2) and creating and manipulating tree-structures. How's that for someone who hasn't written an application in C in 18 years?
There is the concept of a process group. Maybe setpgrp/getpgrp will give a clue? All children, and their children, are part of the same process group. I think this is really coarse grained in that you can do things to all members of the process group, not just specific ones. But maybe you can use this to find who they are. Sorry I cannot say more. I have not really used this.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (3)
-
Aaron Kulkis
-
Jeffrey L. Taylor
-
Roger Oberholtzer