summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/dispatch-conf2
-rw-r--r--pym/_emerge/BinpkgFetcher.py2
-rw-r--r--pym/_emerge/SpawnProcess.py2
-rw-r--r--pym/portage/__init__.py11
-rw-r--r--pym/portage/getbinpkg.py2
-rw-r--r--pym/portage/package/ebuild/doebuild.py4
-rw-r--r--pym/portage/package/ebuild/fetch.py2
-rw-r--r--pym/portage/process.py2
8 files changed, 19 insertions, 8 deletions
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index e5f768056..479647ede 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -462,7 +462,7 @@ def spawn_shell(cmd):
sys.__stdout__.flush()
sys.__stderr__.flush()
spawn([shell, "-c", cmd], env=os.environ,
- fd_pipes = { 0 : sys.__stdin__.fileno(),
+ fd_pipes = { 0 : portage._get_stdin().fileno(),
1 : sys.__stdout__.fileno(),
2 : sys.__stderr__.fileno()})
else:
diff --git a/pym/_emerge/BinpkgFetcher.py b/pym/_emerge/BinpkgFetcher.py
index 1913b4431..14f2552cb 100644
--- a/pym/_emerge/BinpkgFetcher.py
+++ b/pym/_emerge/BinpkgFetcher.py
@@ -91,7 +91,7 @@ class BinpkgFetcher(SpawnProcess):
# Redirect all output to stdout since some fetchers like
# wget pollute stderr (if portage detects a problem then it
# can send it's own message to stderr).
- fd_pipes.setdefault(0, sys.__stdin__.fileno())
+ fd_pipes.setdefault(0, portage._get_stdin().fileno())
fd_pipes.setdefault(1, sys.__stdout__.fileno())
fd_pipes.setdefault(2, sys.__stdout__.fileno())
diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
index d18512b34..45d709517 100644
--- a/pym/_emerge/SpawnProcess.py
+++ b/pym/_emerge/SpawnProcess.py
@@ -50,7 +50,7 @@ class SpawnProcess(SubProcess):
null_input = os.open('/dev/null', os.O_RDWR)
fd_pipes[0] = null_input
- fd_pipes.setdefault(0, sys.__stdin__.fileno())
+ fd_pipes.setdefault(0, portage._get_stdin().fileno())
fd_pipes.setdefault(1, sys.__stdout__.fileno())
fd_pipes.setdefault(2, sys.__stderr__.fileno())
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 3e634b53b..96a4fa98c 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -339,6 +339,17 @@ _internal_warnings = False
_sync_disabled_warnings = False
+def _get_stdin():
+ """
+ Buggy code in python's multiprocessing/process.py closes sys.stdin
+ and reassigns it to open(os.devnull), but fails to update the
+ corresponding __stdin__ reference. So, detect that case and handle
+ it appropriately.
+ """
+ if not sys.__stdin__.closed:
+ return sys.__stdin__
+ return sys.stdin
+
def _shell_quote(s):
"""
Quote a string in double-quotes and use backslashes to
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 28b18a00f..947bd3e92 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -499,7 +499,7 @@ def file_get(baseurl,dest,conn=None,fcmd=None,filename=None):
myfetch = portage.util.shlex_split(fcmd)
myfetch = [varexpand(x, mydict=variables) for x in myfetch]
fd_pipes= {
- 0:sys.__stdin__.fileno(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stdout__.fileno()
}
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index a735ea81b..855c62aed 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -718,7 +718,7 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
mysettings["dbkey"] = ""
pr, pw = os.pipe()
fd_pipes = {
- 0:sys.__stdin__.fileno(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stderr__.fileno(),
9:pw}
@@ -1402,7 +1402,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
fd_pipes = keywords.get("fd_pipes")
if fd_pipes is None:
fd_pipes = {
- 0:sys.__stdin__.fileno(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stderr__.fileno(),
}
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py
index 59d45be05..0a7bf10bb 100644
--- a/pym/portage/package/ebuild/fetch.py
+++ b/pym/portage/package/ebuild/fetch.py
@@ -64,7 +64,7 @@ def _spawn_fetch(settings, args, **kwargs):
if "fd_pipes" not in kwargs:
kwargs["fd_pipes"] = {
- 0 : sys.__stdin__.fileno(),
+ 0 : portage._get_stdin().fileno(),
1 : sys.__stdout__.fileno(),
2 : sys.__stdout__.fileno(),
}
diff --git a/pym/portage/process.py b/pym/portage/process.py
index fbfbde049..63c315423 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -226,7 +226,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
# default to propagating our stdin, stdout and stderr.
if fd_pipes is None:
fd_pipes = {
- 0:sys.__stdin__.fileno(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stderr__.fileno(),
}