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:
# 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())
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())
_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
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()
}
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}
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(),
}
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(),
}
# 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(),
}