diff options
Diffstat (limited to 'base/process/launch_win.cc')
-rw-r--r-- | base/process/launch_win.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc index de05255..edb523b 100644 --- a/base/process/launch_win.cc +++ b/base/process/launch_win.cc @@ -63,8 +63,22 @@ void RouteStdioToConsole() { // stdout/stderr on startup (before the handle IDs can be reused). // _fileno(stdout) will return -2 (_NO_CONSOLE_FILENO) if stdout was // invalid. - if (_fileno(stdout) >= 0 || _fileno(stderr) >= 0) - return; + if (_fileno(stdout) >= 0 || _fileno(stderr) >= 0) { + // _fileno was broken for SUBSYSTEM:WINDOWS from VS2010 to VS2012/2013. + // http://crbug.com/358267. Confirm that the underlying HANDLE is valid + // before aborting. + + // This causes NaCl tests to hang on XP for reasons unclear, perhaps due + // to not being able to inherit handles. Since it's only for debugging, + // and redirecting still works, punt for now. + if (base::win::GetVersion() < base::win::VERSION_VISTA) + return; + + intptr_t stdout_handle = _get_osfhandle(_fileno(stdout)); + intptr_t stderr_handle = _get_osfhandle(_fileno(stderr)); + if (stdout_handle >= 0 || stderr_handle >= 0) + return; + } if (!AttachConsole(ATTACH_PARENT_PROCESS)) { unsigned int result = GetLastError(); |