Q:

Signal/Pause Deadlock

I have hard time managing children processes via signals and shared-memory (I know pipes could have been better). I have the following loop of:
 * parent processing something, then signaling the children and going into pause,
 * children processing something, then signaling the parent and going into pause,
 * etc. etc.

The problem is that sometime after signaling the parent (via kill), the os switch to the parent without ever letting the child to pause(). When it resumes the child (after the parent invoke pause) the child then pauses and I have a deadlock :(.
Any suggestions?

A:

In order to avoid this race, you need to block the signal you are using with sigprocmask().  Then, insted of pause(), use sigsuspend() to atomically unblock the signal and suspend the process.
This will mean that if the signal is sent before the process calls sigsuspend(), it will not be delivered until the sigsuspend().

