Tom Tanner  committed 27d0f42

Revert stdout/stderr to the initial ones in a few places.

There are some situations where scons error messages can just disappear,
and sometimes it's because a build rule or an SConscript or something has
temporarily redirected stdout/stderr.

  • Participants
  • Parent commits 1f3c683

Comments (0)

Files changed (1)

File src/engine/SCons/Script/

     import SCons.Platform.win32
     return SCons.Platform.win32.parallel_msg
+def revert_io():
+    # This call is added to revert stderr and stdout to the original
+    # ones just in case some build rule or something else in the system
+    # has redirected them elsewhere.
+    sys.stderr = sys.__stderr__
+    sys.stdout = sys.__stdout__
 class SConsPrintHelpException(Exception):
         # reading SConscript files and haven't started building
         # things yet, stop regardless of whether they used -i or -k
         # or anything else.
+        revert_io()
         sys.stderr.write("scons: *** %s  Stop.\n" % e)
-        exit_status = 2
-        sys.exit(exit_status)
+        sys.exit(2)
     global sconscript_time
     sconscript_time = time.time() - start_time
         # Build the targets
         nodes = _build_targets(fs, options, targets, target_top)
         if not nodes:
+            revert_io()
             print 'Found nothing to build'
             exit_status = 2
     OptionsParser = parser
-        _exec_main(parser, values)
+        try:
+            _exec_main(parser, values)
+        finally:
+            revert_io()
     except SystemExit, s:
         if s:
             exit_status = s