From b52f5655e41641799bfd3d2248ed6f73db6d5d6b Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Sun, 3 Oct 2021 12:08:47 +0200 Subject: [PATCH] Added comment explaining the DETACHED_PROCESS flag --- src/common/win32/InlineFunc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/win32/InlineFunc.cpp b/src/common/win32/InlineFunc.cpp index 9e255c084..ce0d2701e 100644 --- a/src/common/win32/InlineFunc.cpp +++ b/src/common/win32/InlineFunc.cpp @@ -68,6 +68,9 @@ std::optional CxbxExec(bool useDebugger, HANDLE* hProcess, bool req Using ShellExecute has proper implement. Unfortunately, we need created process handle for Debugger monitor. Plus ShellExecute is high level whilst CreateProcess is low level. We want to use official low level functions as possible to reduce cpu load cycles to get the task done. + + Without the DETACHED_PROCESS flag, the default behavior would be for the new process to inherit the console of the parent process, + which is wrong since we want the emulation process to have its own console allocated with AllocConsole instead. */ if (CreateProcess(nullptr, const_cast(szProcArgsBuffer.c_str()), nullptr, nullptr, false, DETACHED_PROCESS, nullptr, nullptr, &startupInfo, &processInfo) == 0) { return std::make_optional("Failed to create the new emulation process. CreateProcess failed because: " + WinError2Str());