hello all, the attached patch --already committed-- adds a shutdown hook to the Command class in the keytool package.
2006-06-02 Raif S. Naffah <[EMAIL PROTECTED]>
* tools/gnu/classpath/tools/keytool/Command.java (shutdownThread): New
field.
(Command): Add the shutdown hook.
(doCommand): Remove the shutdown hook.
(ShutdownHook): New class.
cheers;
rsn
Index: Command.java
===================================================================
RCS file: /cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/Command.java,v
retrieving revision 1.4
diff -u -r1.4 Command.java
--- Command.java 20 May 2006 01:40:10 -0000 1.4
+++ Command.java 1 Jun 2006 19:26:08 -0000
@@ -168,10 +168,17 @@
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 @@
finally
{
teardown();
+ if (shutdownThread != null)
+ Runtime.getRuntime().removeShutdownHook(shutdownThread);
}
}
@@ -1157,4 +1166,15 @@
return handler;
}
+
+ // Inner class(es) ==========================================================
+
+ private class ShutdownHook
+ extends Thread
+ {
+ public void run()
+ {
+ teardown();
+ }
+ }
}
pgpDnKVKzAkOY.pgp
Description: PGP signature
