fork and sigprocmask as an atomic operation?

From: Till Varoquaux
Date: Fri May 13 2011 - 00:48:29 EST


If I understand properly the idiomatic way to set the signal mask in a
forked of process is to block all signals in the parent process before
calling fork and then setting the desired mask in both processes.

sigprocmask()
..... <-- All the signals are going to be put in the pending list
clone ()
......
sigprocmask() <-- release all the pending signals that we care about.

Now; unless I am missing something this does not seem to play well
with threads. Providing several threads go through that exact dance at
the same time it seems as could this result in the application ending
up with the wrong signal mask?

Is there any good reason to not add a new flag to clone that would
block all signals in the child process?

Cheers,
Til
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/