Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3273)

Unified Diff: base/process/launch_win.cc

Issue 324493003: Another try at fixing --enable-logging on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698