mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 673383 - Output stdout in regular command line on Windows. r=ted
This commit is contained in:
parent
0befee6bf6
commit
e6abaf3f94
@ -366,6 +366,21 @@ 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);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
for ( int i = 1; i < gArgc; i++ ) {
|
||||
if ( strcmp( "-console", gArgv[i] ) == 0
|
||||
||
|
||||
|
Loading…
Reference in New Issue
Block a user