in src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java [139:159]
private void removeShutdownHook() {
if (added.get() && !running.get()) {
final boolean removed = Runtime.getRuntime().removeShutdownHook(destroyProcessThread);
if (!removed) {
System.err.println("Could not remove shutdown hook");
}
// start the hook thread, a unstarted thread may not be eligible for garbage collection Cf.: https://developer.java.sun.com/developer/
// bugParade/bugs/4533087.html
destroyProcessThread.setShouldDestroy(false);
destroyProcessThread.start();
// this should return quickly, since it basically is a NO-OP.
try {
destroyProcessThread.join(20000);
} catch (final InterruptedException ignore) {
// the thread didn't die in time
// it should not kill any processes unexpectedly
}
destroyProcessThread = null;
added.compareAndSet(true, false);
}
}