in src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java [142:165]
private void removeShutdownHook() {
if (added && !running) {
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.:
* http://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 ie) {
// the thread didn't die in time
// it should not kill any processes unexpectedly
}
destroyProcessThread = null;
added = false;
}
}