diff options
-rw-r--r-- | lib/spack/llnl/util/tty/log.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py index 177da3f108..534472dbec 100644 --- a/lib/spack/llnl/util/tty/log.py +++ b/lib/spack/llnl/util/tty/log.py @@ -503,7 +503,7 @@ class nixlog: self._saved_debug = tty._debug # Pipe for redirecting output to logger - read_fd, write_fd = multiprocessing.Pipe(duplex=False) + read_fd, self.write_fd = multiprocessing.Pipe(duplex=False) # Pipe for communication back from the daemon # Currently only used to save echo value between uses @@ -526,7 +526,7 @@ class nixlog: args=( input_fd, read_fd, - write_fd, + self.write_fd, self.echo, self.log_file, child_pipe, @@ -557,9 +557,9 @@ class nixlog: self._saved_stderr = os.dup(sys.stderr.fileno()) # redirect to the pipe we created above - os.dup2(write_fd.fileno(), sys.stdout.fileno()) - os.dup2(write_fd.fileno(), sys.stderr.fileno()) - write_fd.close() + os.dup2(self.write_fd.fileno(), sys.stdout.fileno()) + os.dup2(self.write_fd.fileno(), sys.stderr.fileno()) + self.write_fd.close() else: # Handle I/O the Python way. This won't redirect lower-level @@ -572,7 +572,7 @@ class nixlog: self._saved_stderr = sys.stderr # create a file object for the pipe; redirect to it. - pipe_fd_out = os.fdopen(write_fd.fileno(), "w", closefd=False) + pipe_fd_out = os.fdopen(self.write_fd.fileno(), "w", closefd=False) sys.stdout = pipe_fd_out sys.stderr = pipe_fd_out @@ -608,6 +608,7 @@ class nixlog: else: sys.stdout = self._saved_stdout sys.stderr = self._saved_stderr + self.write_fd.close() # print log contents in parent if needed. if self.log_file.write_in_parent: |