Merge pull request #2282 from ergo720/freopen_invalid_handle
Fixed invalid handle exception in freopen
This commit is contained in:
commit
629d6d2054
|
@ -68,8 +68,11 @@ 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, 0, nullptr, nullptr, &startupInfo, &processInfo) == 0) {
|
||||
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());
|
||||
}
|
||||
CloseHandle(processInfo.hThread);
|
||||
|
|
Loading…
Reference in New Issue