implement spawn_doom() for windows
This commit is contained in:
parent
ddc51a3ccc
commit
709cf432f9
1 changed files with 32 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <signal.h>
|
||||
#ifdef __WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <spawn.h>
|
||||
#include <sys/wait.h>
|
||||
|
@ -119,6 +120,37 @@ char **__environ = environ;
|
|||
#ifdef __WIN32
|
||||
inline void spawn_doom(ControllerContext &ctx)
|
||||
{
|
||||
(void) ctx;
|
||||
|
||||
// Source: https://learn.microsoft.com/en-us/windows/win32/procthread/creating-processes
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
|
||||
char cmdLine[256];
|
||||
snprintf(cmdLine, sizeof(cmdLine), "%s", DOOM_EXECUTABLE);
|
||||
|
||||
// Start the child process.
|
||||
if (!CreateProcess(NULL, // No module name (use command line)
|
||||
cmdLine, // Command line
|
||||
NULL, // Process handle not inheritable
|
||||
NULL, // Thread handle not inheritable
|
||||
FALSE, // Set handle inheritance to FALSE
|
||||
0, // No creation flags
|
||||
NULL, // Use parent's environment block
|
||||
NULL, // Use parent's starting directory
|
||||
&si, // Pointer to STARTUPINFO structure
|
||||
&pi) // Pointer to PROCESS_INFORMATION structure
|
||||
)
|
||||
{
|
||||
log_error("CreateProcess failed (%d)", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
log_info("Spawned new %s, pid=%d", cmdLine, pi.dwProcessId);
|
||||
}
|
||||
#else
|
||||
void spawn_doom_posix_spawn(ControllerContext &ctx)
|
||||
|
|
Loading…
Reference in a new issue