summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRaif S. Naffah <raif@swiftdsl.com.au>2006-06-01 19:31:46 +0000
committerRaif S. Naffah <raif@swiftdsl.com.au>2006-06-01 19:31:46 +0000
commit64a076cd2e67b130ed254fb748fe34f6d1254e42 (patch)
treedfce68bf68569dd98db8d6ee52d35668314e8b1d /tools
parente0506fe859fac7da087a6378a305cbbeda962561 (diff)
downloadclasspath-64a076cd2e67b130ed254fb748fe34f6d1254e42.tar.gz
2006-06-02 Raif S. Naffah <raif@swiftdsl.com.au>
* tools/gnu/classpath/tools/keytool/Command.java (shutdownThread): New field. (Command): Add the shutdown hook. (doCommand): Remove the shutdown hook. (ShutdownHook): New class.
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();
+ }
+ }
}