Skip to content

Signal all processes in process group except self

I am writing a program which multiple processes will run concurrently. In this program, there is a need for one process to suspend all other participants temporarily.

In order to spare myself the overhead of tabulating all participant process ID’s in a shared page and signaling them individually, I have created a process group that all participants join.

To suspend all processes in a group, I initially used the call:

killpg(0, SIGSTOP);

and intended to resume them after with:

killpg(0, SIGCONT);

I have quickly realized though, that this also suspends the calling process, as long as it too is a member of the process group. Because any process should be able to suspend the other members of the group, I cannot dedicate one process for this task. My question, thus, is whether there is a system call or mechanism to suspend all group members with the exception of the caller. I am looking for something specifically for Linux.



You cannot send a signal to all members of the group except the sender, but there is a reasonable workaround. Rather than using SIGSTOP (which cannot be handled or ignored), you can use SIGTSTP which by default will have the same effect as SIGSTOP, stopping the process which receives it. To avoid stopping the sender, simply have the sender ignore the signal before it is sent, and then reset the signal disposition to the default after sending signal to the process group.