MergeProcess,spawn: 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@igpm.rwth-aachen.de>
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py
index fefdf863..3715500 100644
--- a/pym/portage/dbapi/_MergeProcess.py
+++ b/pym/portage/dbapi/_MergeProcess.py
@@ -178,6 +178,16 @@
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).
diff --git a/pym/portage/process.py b/pym/portage/process.py
index 2af783e..fd32673 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -472,6 +472,16 @@
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
+
# Quiet killing of subprocesses by SIGPIPE (see bug #309001).
signal.signal(signal.SIGPIPE, signal.SIG_DFL)