mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Only reopen stdout, stderr, stdin if they haven't already been opened by a redirect
And fix a warning along the way
This commit is contained in:
parent
70f4b0d5dc
commit
d4933111db
1 changed files with 7 additions and 3 deletions
|
|
@ -261,9 +261,13 @@ bool JUCEApplicationBase::initialiseApp()
|
|||
if (AttachConsole (ATTACH_PARENT_PROCESS) != 0)
|
||||
{
|
||||
// if we've launched a GUI app from cmd.exe or PowerShell, we need this to enable printf etc.
|
||||
freopen("CON", "w", stdout);
|
||||
freopen("CON", "w", stderr);
|
||||
freopen("CON", "r", stdin);
|
||||
// However, only reassign stdout, stderr, stdin if they have not been already opened by
|
||||
// a redirect or similar.
|
||||
FILE* ignore;
|
||||
|
||||
if (_fileno(stdout) < 0) freopen_s (&ignore, "CONOUT$", "w", stdout);
|
||||
if (_fileno(stderr) < 0) freopen_s (&ignore, "CONOUT$", "w", stderr);
|
||||
if (_fileno(stdin) < 0) freopen_s (&ignore, "CONIN$", "r", stdin);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue