What's the easiest way to duplicate the current process, to spawn another instance in Windows? I know Linux has fork()
, but all I need is to run main in the same process again, probably using CreateProcess()
with the correct arguments.
As @DavidHeffernan commented:
STARTUPINFO si;
::memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
::CreateProcess(NULL, ::GetCommandLine(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);