This content has been marked as final. Show 3 replies
When you use Runtime.getRuntime.exec() the command is sent from you terminal and not from the JVM.Complete nonsense. The JVM calls one of the varieties of exec(2), or WinExec() on Windows. What you describe neither exists nor even makes sense.
You can try to apply a stop command which you catch in OS space and close the exec correctly, so the application starting it will know about it.More nonsense.
Where do you get this stuff?
997124 wrote:Presumably all of that means that
...before I get a chance to write the proper shutdown command to its standard in.
- you are using Runtime.addShutdownHook()
- You have explicitly determine that your shutdown hook does not complete. That means that you used a mechanism such as logging to determine that you method was running.
- Your method is not throwing exception - you have catch(Throwable) and log that.
If all of the above is true and only if it is true then your only alternative would be to put a keep alive in place. That would be a communcation from the calling app to the child app such that the child app terminates itself if the calling app doesn't send it. That is the only safe way since there are cases where shutdown hooks would not be called. You can also write a clean up app that looks for orphaned child processes and kills them.