c - How to send SIGSTOP to all processes that launched from a shell script -


i have shell script launches 4 other binaries. sending sigstop shell script. stop other 4 processes also? if not, should forward sigstop these processes? similar case sigcont.

i have c source code 4 binaries.

you can call setpgid() in forked child process execute shell script. give spawned processes shell script same group id child process. can use killpg() send signal entire group processes in group receive.

for instance, if inside child process called setpgid(0, 0), setup special instance child-process' group id set same value child's pid. processes overlaid on child process using 1 of exec family of functions have same group-id value child had. in addition, processes newly overlaid process may spawn have same group id (i.e., shell-script). can then, using killpg(), send signal processes sharing group id value using child's pid value fork() returned since group id of child process same value child's pid after setpgid(0, 0) call.

if using fork(), depending on how need send signals group parent process may create synchronization issues ... example, want send signal process group right after forking child process. there 2 work-arounds this: either 1) use vfork() instead of fork, parent suspended until child has changed it's group-id , called exec, or 2) call setpgid() in parent process as as in child-process, in parent, rather using setgpid(0, 0) in child, can use setpgid(child_pid, child_pid). won't matter call successful (one of them successful, , other fail eacces), , successive signals sent parent wil go valid group id.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -