Chromium Code Reviews| Index: base/process/launch_win.cc |
| diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc |
| index de05255d90aaa3fecbf50c386c361920ae02571d..2aebcdf9527e220eb3fcfb162e99172b8cb38f49 100644 |
| --- a/base/process/launch_win.cc |
| +++ b/base/process/launch_win.cc |
| @@ -63,8 +63,15 @@ 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://connect.microsoft.com/VisualStudio/feedback/details/785119/ |
| + // Confirm that the underlying HANDLE is valid before aborting. |
| + intptr_t stdout_handle = _get_osfhandle(_fileno(stdout)); |
|
Mark Seaborn
2014/03/31 18:39:08
Does intptr_t work on the MSVC toolchains that Chr
scottmg
2014/03/31 18:46:13
Assuming it works for the various compilers of bas
|
| + 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(); |