Signals could be blocked by something like:
#include <unistd.h> #include <signal.h> int main(int argc, char * const argv[]) { sigset_t set; sigfillset(&set); sigprocmask(SIG_BLOCK, &set, NULL); execv("/bin/hg", argv); return 0; }
One of the problems is if SIGCHLD is blocked, chgserver would not reap
zombie workers since it depends on SIGCHLD handler entirely.
While it's the parent process to blame but it seems a good idea to just
unblock the signal from hg. FWIW git does that for SIGPIPE already [1].
Unfortunately Python 2 does not reset or provide APIs to change signal
masks. Therefore let's add one in osutil. Note: Python 3.3 introduced
signal.pthread_sigmask which solves the problem.
sigprocmask is part of POSIX [2] so there is no feature testing in
setup.py.
[1]: https://github.com/git/git/commit/7559a1be8a0afb10df41d25e4cf4c5285a5faef1
[2]: http://pubs.opengroup.org/onlinepubs/7908799/xsh/sigprocmask.html
Nit: sigaddset() may raise EINVAL if the given signum is invalid.
Maybe it's also better to check the result of sigemptyset() for clarity.