Stop process gracefully
Dear experts,
please tell me how can I stop any process gracefully. I am executing a java application from another java application. Something like
Process proc = Runtime.getRuntime().exec("java .....");
Now I need to stop the inner process. How can I do this? If I use Process.destroy() then the shutdown hook thread of the inner process is not executed. But that is important for the inner process. So not possible to use destroy() method. Please tell me how can I stop the inner process gracefully.
Gracefully stopping a non-cooperating program is not possible. For graceful stopping the process has to have the ability to ignore the stop-signal for some time at least. And as long as it has that ability you can't force it to stop.
The only way to gracefully stop any process is that you tell it to stop and it does so. Unless it's programmed to respond to such a signal there is no way to "force it to gracefully stop".
What makes you think so? If you've got some information that says you can do so, please share it with us. What do you think that you can achieve by just saying "but tell me!"? You didn't get a solution (probably because there is no solution) and didn't provide any more information, so the answer doesn't change.
You might want to look up how to [url=http://www.catb.org/~esr/faqs/smart-questions.html]ask questions the smart way[/url].