The documentation for the _spawn family of functions say they return a HANDLE when called with _P_NOWAIT.
I was hoping to use this handle with TerminateProcess(h, 1);
(In case the started process misbehaves.)
HANDLE h = (HANDLE) _spawnl(_P_NOWAIT, "C:\\temp\\hello.exe", NULL);
However, I don't understand the difference between these handles and the PID shown in the Task Manager.
The spawn function only ever returns very low values, like "248" and not what actually shows in Task Manager.
Can I use the return value of _spawn to kill a process and if so, how?
CodePudding user response:
This did the trick:
auto process_handle = (HANDLE)_wspawnv(_P_NOWAIT, argv[1], &argv[1]);
auto procID = GetProcessId(ID);
thanks sj95126