Index: base/process/launch_win.cc |
diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc |
index 9e4db384ebb401a967a68fb30157826906549845..66e68e24dfd96c5d153ad84297fa236d1dde3a22 100644 |
--- a/base/process/launch_win.cc |
+++ b/base/process/launch_win.cc |
@@ -64,7 +64,17 @@ 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) |
+ |
+ // TODO(scottmg): |
+ // Unfortunately _fileno was broken in VS2012, and is still broken in VS2013. |
+ // https://connect.microsoft.com/VisualStudio/feedback/details/785119/ |
+ // http://crbug.com/358267 |
+ // It never returns -2 as it is documented to do (and per above) when in a |
+ // windowed application without a console. As a result, we have to use |
+ // GetStdHandle, even though it's not strictly correct. Hopefully this can |
+ // be removed after a future revision of the CRT. |
+ if ((_fileno(stdout) >= 0 && GetStdHandle(STD_OUTPUT_HANDLE) != NULL) || |
+ (_fileno(stderr) >= 0 && GetStdHandle(STD_ERROR_HANDLE)) != NULL) |
return; |
if (!AttachConsole(ATTACH_PARENT_PROCESS)) { |