mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 787313 - Add /attach-console
argument on Windows in order to attach Firefox std IO to parent console. r=ted
This commit is contained in:
parent
dd9f763986
commit
91d710b076
@ -332,22 +332,6 @@ NS_IMPL_RELEASE_INHERITED(nsNativeAppSupportWin, nsNativeAppSupportBase)
|
||||
|
||||
void
|
||||
nsNativeAppSupportWin::CheckConsole() {
|
||||
// Try to attach console to the parent process.
|
||||
// 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
|
||||
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("CONOUT$", "w", stderr);
|
||||
if (_fileno(stdin) == -1 || _get_osfhandle(fileno(stdin)) == -1)
|
||||
freopen("CONIN$", "r", stdin);
|
||||
}
|
||||
|
||||
for ( int i = 1; i < gArgc; i++ ) {
|
||||
if ( strcmp( "-console", gArgv[i] ) == 0
|
||||
||
|
||||
@ -408,8 +392,25 @@ nsNativeAppSupportWin::CheckConsole() {
|
||||
|
||||
--gArgc;
|
||||
|
||||
// Don't bother doing this more than once.
|
||||
break;
|
||||
} else if ( strcmp( "-attach-console", gArgv[i] ) == 0
|
||||
||
|
||||
strcmp( "/attach-console", gArgv[i] ) == 0 ) {
|
||||
// Try to attach console to the parent process.
|
||||
// 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
|
||||
if (_fileno(stdout) == -1 ||
|
||||
_get_osfhandle(fileno(stdout)) == -1)
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
if (_fileno(stderr) == -1 ||
|
||||
_get_osfhandle(fileno(stderr)) == -1)
|
||||
freopen("CONERR$", "w", stderr);
|
||||
if (_fileno(stdin) == -1 || _get_osfhandle(fileno(stdin)) == -1)
|
||||
freopen("CONIN$", "r", stdin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user