summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Kosukhin <skosukhin@gmail.com>2016-12-12 20:55:13 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2016-12-12 11:55:13 -0800
commit8f28c9009e2e71c71dad69bfe277bfe973cb49dd (patch)
tree1cfbe84afcbf0d11b3bb61910138a4deb5414140 /lib
parenteb645a8e46a9e0144149991d486593ca825b0b6c (diff)
downloadspack-8f28c9009e2e71c71dad69bfe277bfe973cb49dd.tar.gz
spack-8f28c9009e2e71c71dad69bfe277bfe973cb49dd.tar.bz2
spack-8f28c9009e2e71c71dad69bfe277bfe973cb49dd.tar.xz
spack-8f28c9009e2e71c71dad69bfe277bfe973cb49dd.zip
Set parent process's input stream inside the build process. (#2535)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/package.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 31d08be456..3502eb2931 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1218,6 +1218,19 @@ class PackageBase(object):
"""Forked for each build. Has its own process and python
module space set up by build_environment.fork()."""
+ # We are in the child process. This means that our sys.stdin is
+ # equal to open(os.devnull). Python did this to prevent our process
+ # and the parent process from possible simultaneous reading from
+ # the original standard input. But we assume that the parent
+ # process is not going to read from it till we are done here,
+ # otherwise it should not have passed us the copy of the stream.
+ # Thus, we are free to work with the the copy (input_stream)
+ # however we want. For example, we might want to call functions
+ # (e.g. raw_input()) that implicitly read from whatever stream is
+ # assigned to sys.stdin. Since we want them to work with the
+ # original input stream, we are making the following assignment:
+ sys.stdin = input_stream
+
start_time = time.time()
if not fake:
if not skip_patch: