From d970453a082c7f03178f18129523cb2b339872b9 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Thu, 24 May 2012 16:11:34 +0200 Subject: [PATCH] Bug 753856 - Use CONOUT$ for stderr on Windows. r=ted --- toolkit/xre/nsNativeAppSupportWin.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/toolkit/xre/nsNativeAppSupportWin.cpp b/toolkit/xre/nsNativeAppSupportWin.cpp index b7832cdc0c13..cdd8735c563d 100644 --- a/toolkit/xre/nsNativeAppSupportWin.cpp +++ b/toolkit/xre/nsNativeAppSupportWin.cpp @@ -336,15 +336,16 @@ nsNativeAppSupportWin::CheckConsole() { // It will succeed when the parent process is a command line, // so that stdio will be displayed in it. if (AttachConsole(ATTACH_PARENT_PROCESS)) { - // Change std handles to refer to new console handles. - // Before doing so, ensure that stdout/stderr haven't been redirected to a valid file + // Change std handles to refer to new console handles. Before doing so, + // ensure that stdout/stderr haven't been redirected to a valid file if (_fileno(stdout) == -1 || _get_osfhandle(fileno(stdout)) == -1) freopen("CONOUT$", "w", stdout); + // There isn't any `CONERR$`, so that we merge stderr into CONOUT$ + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms683231%28v=vs.85%29.aspx if (_fileno(stderr) == -1 || _get_osfhandle(fileno(stderr)) == -1) - freopen("CONERR$", "w", stderr); + freopen("CONOUT$", "w", stderr); if (_fileno(stdin) == -1 || _get_osfhandle(fileno(stdin)) == -1) freopen("CONIN$", "r", stdin); - return; } for ( int i = 1; i < gArgc; i++ ) {