From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 89A491382C5 for ; Thu, 17 May 2018 18:40:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B2BACE0ACB; Thu, 17 May 2018 18:40:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8A165E0ACB for ; Thu, 17 May 2018 18:40:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 26529335C49 for ; Thu, 17 May 2018 18:40:51 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 604FB299 for ; Thu, 17 May 2018 18:40:49 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1526582307.b2a5f03abc0c172b6189226e6f9a7491a002cf51.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/_MergeProcess.py pym/portage/process.py X-VCS-Directories: pym/portage/dbapi/ pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: b2a5f03abc0c172b6189226e6f9a7491a002cf51 X-VCS-Branch: master Date: Thu, 17 May 2018 18:40:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 95b39dcb-04f7-4fa9-b8a9-e0012ac923e6 X-Archives-Hash: 1b928fb5676dae0a2ec82d9ee12c4514 commit: b2a5f03abc0c172b6189226e6f9a7491a002cf51 Author: Zac Medico gentoo org> AuthorDate: Thu May 17 18:38:27 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Thu May 17 18:38:27 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b2a5f03a 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 igpm.rwth-aachen.de> pym/portage/dbapi/_MergeProcess.py | 10 ++++++++++ pym/portage/process.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py index fefdf8635..371550079 100644 --- a/pym/portage/dbapi/_MergeProcess.py +++ b/pym/portage/dbapi/_MergeProcess.py @@ -178,6 +178,16 @@ class MergeProcess(ForkProcess): 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 2af783e22..fd326731a 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -472,6 +472,16 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask, 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)