mirror of
https://github.com/grumpycoders/pcsx-redux.git
synced 2026-10-12 02:15:13 +00:00
main: keep a redirected stdout on Windows instead of opening a console
With -no-ui, -cli, -tui or -stdout the process always called AllocConsole and reopened stdout onto it, so a parent capturing the output through a pipe got nothing and a console window popped up beside it. Skip the console when the standard output handle is already a pipe or a file.
This commit is contained in:
+5
-1
@@ -239,7 +239,11 @@ int pcsxMain(int argc, char **argv) {
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (args.get<bool>("stdout") || args.get<bool>("no-ui") || args.get<bool>("cli") || args.get<bool>("tui")) {
|
||||
if (AllocConsole()) {
|
||||
// A parent that captures our output hands us a pipe or a file; keep it
|
||||
// instead of opening a console window nobody reads.
|
||||
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
bool redirected = out && out != INVALID_HANDLE_VALUE && GetFileType(out) != FILE_TYPE_UNKNOWN;
|
||||
if (!redirected && AllocConsole()) {
|
||||
freopen("CONIN$", "r", stdin);
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
freopen("CONOUT$", "w", stderr);
|
||||
|
||||
Reference in New Issue
Block a user