@@ -116,8 +116,10 @@ class ProcessDestroyer implements Runnable {
removeShutdownHookMethod =
removeShutdownHookMethod =
Runtime.class.getMethod("removeShutdownHook", paramTypes);
Runtime.class.getMethod("removeShutdownHook", paramTypes);
// wait to add shutdown hook as needed
// wait to add shutdown hook as needed
} catch (Exception e) {
} catch (NoSuchMethod Exception e) {
// it just won't be added as a shutdown hook... :(
// it just won't be added as a shutdown hook... :(
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@@ -133,9 +135,9 @@ class ProcessDestroyer implements Runnable {
addShutdownHookMethod.invoke(Runtime.getRuntime(), args);
addShutdownHookMethod.invoke(Runtime.getRuntime(), args);
added = true;
added = true;
} catch (IllegalAccessException e) {
} catch (IllegalAccessException e) {
// it just won't be added as a shutdown hook... :(
e.printStackTrace();
} catch (InvocationTargetException e) {
} catch (InvocationTargetException e) {
// it just won't be added as a shutdown hook... :(
e.printStackTrace();
}
}
}
}
}
}
@@ -157,6 +159,7 @@ class ProcessDestroyer implements Runnable {
}
}
// start the hook thread, a unstarted thread may not be
// start the hook thread, a unstarted thread may not be
// eligible for garbage collection
// eligible for garbage collection
// Cf.: http://developer.java.sun.com/developer/bugParade/bugs/4533087.html
destroyProcessThread.setShouldDestroy(false);
destroyProcessThread.setShouldDestroy(false);
destroyProcessThread.start();
destroyProcessThread.start();
// this should return quickly, since Process.destroy()
// this should return quickly, since Process.destroy()
@@ -169,7 +172,9 @@ class ProcessDestroyer implements Runnable {
destroyProcessThread = null;
destroyProcessThread = null;
added = false;
added = false;
} catch (IllegalAccessException e) {
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
}
}