I am looking for a Java tool/package/library that will allow me to force-kill a child process.
This tool/package/library must work on Windows platform (mandatory). Support for Linux/Unix is desired.
My Java code creates a child process that will simply not react to the standard Java way for killing a child process: process.destroy(), and, since I do not have the child's source code, I cannot program it to better handle termination requests.
I have tried closing the child process' error input and output stream before calling destroy(), and for no effect.
I have even tried passing ctrlBreak signal (char=3) directly into child.getOutputStream(), and again have received the same results.
The workaround i have finally managed to find was to: 1. Obtain the child's PID upon its creation This can be done in Windows by diffinf the process lists before and after the child's creation (getRuntime().exec("tasklist /v")
But - this is complex code i have no desire to debug and maintain, plus the problem itself, i have no doubt, was previously encountered by many other java developers, which leads me to the hope that such a Java tool/package/library already exists.
I just don't know its name...
Your help will be appreciated.
PS: My child process was created by Runtime.getRuntime().exec(cmd), but i get the same behaviour using a ProcessBuilder.