comparison mercurial/util.py @ 35460:8652ab4046e4

osutil: add a function to unblock signals 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 Differential Revision: https://phab.mercurial-scm.org/D1736
author Jun Wu <quark@fb.com>
date Wed, 20 Dec 2017 02:13:35 -0800
parents 25c543944bc0
children beede158ea8a
comparison
equal deleted inserted replaced
35459:b520c8f98e1e 35460:8652ab4046e4
159 recvfds = osutil.recvfds 159 recvfds = osutil.recvfds
160 except AttributeError: 160 except AttributeError:
161 pass 161 pass
162 try: 162 try:
163 setprocname = osutil.setprocname 163 setprocname = osutil.setprocname
164 except AttributeError:
165 pass
166 try:
167 unblocksignal = osutil.unblocksignal
164 except AttributeError: 168 except AttributeError:
165 pass 169 pass
166 170
167 # Python compatibility 171 # Python compatibility
168 172