summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/gnu/classpath/tools/keytool/Command.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/gnu/classpath/tools/keytool/Command.java b/tools/gnu/classpath/tools/keytool/Command.java
index 0d8c56334..0811074b8 100644
--- a/tools/gnu/classpath/tools/keytool/Command.java
+++ b/tools/gnu/classpath/tools/keytool/Command.java
@@ -168,10 +168,17 @@ abstract class Command
private int providerNdx = -2;
/** The callback handler to use when needing to interact with user. */
private CallbackHandler handler;
+ /** The shutdown hook. */
+ private ShutdownHook shutdownThread;
// Constructor(s) -----------------------------------------------------------
- // default 0-arguments constructor
+ protected Command()
+ {
+ super();
+ shutdownThread = new ShutdownHook();
+ Runtime.getRuntime().addShutdownHook(shutdownThread);
+ }
// Methods ------------------------------------------------------------------
@@ -201,6 +208,8 @@ abstract class Command
finally
{
teardown();
+ if (shutdownThread != null)
+ Runtime.getRuntime().removeShutdownHook(shutdownThread);
}
}
@@ -1157,4 +1166,15 @@ abstract class Command
return handler;
}
+
+ // Inner class(es) ==========================================================
+
+ private class ShutdownHook
+ extends Thread
+ {
+ public void run()
+ {
+ teardown();
+ }
+ }
}