Terminating a process created with spawnv
I don't experience any processes at all, but what I'm set up should be very simple. All I do is create a process like this:
int spawnId = spawnv(_P_NOWAIT,"wgetlocal.exe",my_env);
Now what I want to do is kill this program after a certain amount of time. However, the returned spawnId is not what I need if called, for example taskkill /PID [number] /F
.
I tried using otherId2 = GetWindowThreadProcessId((HWND)spawnId,OUT otherId1)
, but again, neither otherId1
or otherId2
nor gave the correct PID.
If anyone can help me I would be grateful. Regards, Roald
The return value from asynchronous
_spawnv
or_wspawnv
(_P_NOWAIT
or_P_NOWAITO
specified for mode) is a handle to the process.
Once you have a handle to a process, you can use TerminateProcess
.
Handle types are not interchangeable. You cannot print a handle to a process before HWND
and suddenly become a handle to a window.
a source to share