I have a little windows c++ program that just fires off other programs, but I find when I kill my parent program, all the children die. I want to spawn them off with no relation to the parent anymore. I don't want to wait for output, I don't even care too much if it worked or not. But it is important that it not be tied to the parent process, because it can go away at random. The docs aren't terribly forthcoming on this subject.
This is what I've got.
if (CreateProcess(NULL, s, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
{
// don't wait for it to finish.
//::WaitForSingleObject(processInfo.hProcess, INFINITE);
// free up resources...
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
else
log error...
You simply need to pass CREATE_NEW_PROCESS_GROUP
in the dwCreationFlags
parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With