in my java program. I call an external program through Runtime.execand call Process.waitForto wait for its completion. This is a somewhat lengthy script. I want to make sure that if something goes wrong with my java application (for example, it will be killed from the outside, for example, which sometimes happens sometimes in my case), the external script run will also die.
I looked at Runtime.addShutdownHookwhich may be suitable for this, but it clearly states that, for example, SIGKILLcannot be guaranteed whether the shutdownhook will work or not.
Is there any other way to ensure that an external program launched from Java will die with the calling Java process?
thank
source
share