commit: b28b01a78e4cc0199111e804af5b56a33319356d Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Mon May 14 15:33:15 2018 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Mon May 14 15:35:53 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b28b01a7
ForkProcess: unregister SIGCHLD and wakeup_fd (bug 655656) In order to prevent forked processes from invoking the parent process's SIGCHLD handler and writing to wakeup_fd (triggering BlockingIOError), unregister the SIGCHLD and wakeup_fd. Bug: https://bugs.gentoo.org/655656 Reported-by: Helmut Jarausch <jarausch <AT> igpm.rwth-aachen.de> pym/portage/util/_async/ForkProcess.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pym/portage/util/_async/ForkProcess.py b/pym/portage/util/_async/ForkProcess.py index 25f72d308..d84e93833 100644 --- a/pym/portage/util/_async/ForkProcess.py +++ b/pym/portage/util/_async/ForkProcess.py @@ -37,6 +37,16 @@ class ForkProcess(SpawnProcess): signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGTERM, signal.SIG_DFL) + # Unregister SIGCHLD handler and wakeup_fd for the parent + # process's event loop (bug 655656). + signal.signal(signal.SIGCHLD, signal.SIG_DFL) + try: + wakeup_fd = signal.set_wakeup_fd(-1) + if wakeup_fd > 0: + os.close(wakeup_fd) + except (ValueError, OSError): + pass + portage.locks._close_fds() # We don't exec, so use close_fds=False # (see _setup_pipes docstring).