From 617c0ebf31f09e424442e0bc2e7e5b1c6407a056 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 1 Sep 2013 17:55:21 -0700 Subject: [PATCH] _setup_pipes: fix for Python 3.1 to 3.3 This fixes a case where /dev/null stdin fails to inherit since commit bd2128b7a750a68470f857162784e55b8ac39de2. --- pym/portage/process.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pym/portage/process.py b/pym/portage/process.py index 2a2fcac77..9ae7a55ff 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -583,9 +583,14 @@ def _setup_pipes(fd_pipes, close_fds=True, inheritable=None): if oldfd != newfd: os.dup2(oldfd, newfd) - if old_fdflags is None: - old_fdflags = fcntl.fcntl(oldfd, fcntl.F_GETFD) - fcntl.fcntl(newfd, fcntl.F_SETFD, old_fdflags) + if _set_inheritable is not None: + # Don't do this unless _set_inheritable is available, + # since it's used below to ensure correct state, and + # otherwise /dev/null stdin fails to inherit (at least + # with Python versions from 3.1 to 3.3). + if old_fdflags is None: + old_fdflags = fcntl.fcntl(oldfd, fcntl.F_GETFD) + fcntl.fcntl(newfd, fcntl.F_SETFD, old_fdflags) if _set_inheritable is not None: -- 2.26.2