Added comment explaining the DETACHED_PROCESS flag

This commit is contained in:
ergo720 2021-10-03 12:08:47 +02:00
parent 35072da2ea
commit b52f5655e4
1 changed files with 3 additions and 0 deletions

View File

@ -68,6 +68,9 @@ std::optional<std::string> 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<LPSTR>(szProcArgsBuffer.c_str()), nullptr, nullptr, false, DETACHED_PROCESS, nullptr, nullptr, &startupInfo, &processInfo) == 0) {
return std::make_optional<std::string>("Failed to create the new emulation process. CreateProcess failed because: " + WinError2Str());