Skip to content

Commit d4488ff

Browse files
committed
Re-use parent console if it's available
* This means we won't get an ugly console window popping up when running renderdoccmd on windows, but if we run it from a terminal then we'll get output as normal. * One downside is that cmd.exe seems to snoop the exe type (GUI or console) and if it's a GUI application it returns to the prompt immediately. bash for example though waits for process termination. * The other is that pipe redirects to file don't work properly.
1 parent 24518e0 commit d4488ff

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

renderdoccmd/renderdoccmd_win32.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,15 @@ int WINAPI wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInstance, _In_
808808
LPWSTR *wargv;
809809
int argc;
810810

811+
if(AttachConsole(ATTACH_PARENT_PROCESS))
812+
{
813+
freopen("CONOUT$", "w", stdout);
814+
freopen("CONOUT$", "w", stderr);
815+
816+
std::cout.sync_with_stdio();
817+
std::cerr.sync_with_stdio();
818+
}
819+
811820
wargv = CommandLineToArgvW(GetCommandLine(), &argc);
812821

813822
std::vector<std::string> argv;

0 commit comments

Comments
 (0)