Kill orphan processes
My program launch an aplication, ie. called APL.exe. Also APL.exe launch console applications CON1.exe and CON2.exe.
My application can be launched twice in the same machine, so there could be two instances of CON1.exe and CON2.exe.
Sametimes, APL.exe exits, but CON1.exe and CON2.exe for that proccess remain without killing, so they are orphan. It is no often but it happens.
I need a method to kill CON1.exe and CON2.exe with are orphan, as the other CON1.exe and CON2.exe are running under a running instance of APL.exe.
Are there any way to do this?
thx in advance
How are these applications launched, and do you have any control over their source code?
APL.exe is launched by me. CON1.exe and CON2.exe are launched by apl.exe in a no-windows state. It looks is proccess intercomunication via stdin and stdout.
Originally Posted by matsp
I dont have any control over source code of them.
I suppose this can be done, because process explorer of sysinternal show tree dependences of processes, and show the orphans. If this tool is capable of recognize them then must be a way to do it.
There is a way to do that, but procexp uses internal data structures [guess why the company is called "sysINTERNALs"?], so you may not be able to use that.
Not sure I have a solution.
You can build a process tree using the data returned by CreateToolHelp32Snapshot and Process32(First/Next), specifically the th32ParentProcessID and th32ProcessID members of the PROCESSENTRY32 struct.
Yes, it's even a Win32 FAQ (since Win95)... see Google Groups, Win32
Originally Posted by Kempelen