Console handling: VS2015 seems to only work with redirection when both stdout and stderr are redirected; so show a message box error when redirecting only one stream.
This commit is contained in:
parent
1711592e64
commit
906813c90b
@ -260,13 +260,10 @@ public:
|
|||||||
* to disappear)
|
* to disappear)
|
||||||
*/
|
*/
|
||||||
if (m_stdout_isRedirectedAlready){
|
if (m_stdout_isRedirectedAlready){
|
||||||
if (!m_stderr_isRedirectedAlready)
|
if (!m_stderr_isRedirectedAlready) {
|
||||||
*stderr = *_fdopen(_open_osfhandle((intptr_t) GetStdHandle(STD_OUTPUT_HANDLE), _O_WRONLY), "a");
|
MessageBox(0, "Redirection only works when you use 2>&1 before using > or |\r\n(e.g. fgfs 2>&1 | more)", "Simgear Error", MB_OK | MB_ICONERROR);
|
||||||
else
|
exit(3);
|
||||||
*stderr = *_fdopen(_open_osfhandle((intptr_t) GetStdHandle(STD_ERROR_HANDLE), _O_WRONLY), "a");
|
}
|
||||||
|
|
||||||
*stdout = *_fdopen(_open_osfhandle((intptr_t) GetStdHandle(STD_OUTPUT_HANDLE), _O_WRONLY), "a");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Attempt to attach to the console process of the parent process; when launched from cmd.exe this should be the console,
|
* Attempt to attach to the console process of the parent process; when launched from cmd.exe this should be the console,
|
||||||
@ -283,13 +280,13 @@ public:
|
|||||||
if (!m_stdout_isRedirectedAlready)
|
if (!m_stdout_isRedirectedAlready)
|
||||||
{
|
{
|
||||||
stdout_isNull = true;
|
stdout_isNull = true;
|
||||||
freopen("NUL$", "w", stdout);
|
freopen("NUL", "w", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_stderr_isRedirectedAlready)
|
if (!m_stderr_isRedirectedAlready)
|
||||||
{
|
{
|
||||||
stderr_isNull = true;
|
stderr_isNull = true;
|
||||||
freopen("NUL$", "w", stderr);
|
freopen("NUL", "w", stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user