36 * @author Mark Reinhold 37 * @since 1.3 38 */ 39 40 class Terminator { 41 42 private static SignalHandler handler = null; 43 44 /* Invocations of setup and teardown are already synchronized 45 * on the shutdown lock, so no further synchronization is needed here 46 */ 47 48 static void setup() { 49 if (handler != null) return; 50 SignalHandler sh = new SignalHandler() { 51 public void handle(Signal sig) { 52 Shutdown.exit(sig.getNumber() + 0200); 53 } 54 }; 55 handler = sh; 56 try { 57 Signal.handle(new Signal("HUP"), sh); 58 Signal.handle(new Signal("INT"), sh); 59 Signal.handle(new Signal("TERM"), sh); 60 } catch (IllegalArgumentException e) { 61 // When -Xrs is specified the user is responsible for 62 // ensuring that shutdown hooks are run by calling 63 // System.exit() 64 } 65 } 66 67 static void teardown() { 68 /* The current sun.misc.Signal class does not support 69 * the cancellation of handlers 70 */ 71 } 72 73 } | 36 * @author Mark Reinhold 37 * @since 1.3 38 */ 39 40 class Terminator { 41 42 private static SignalHandler handler = null; 43 44 /* Invocations of setup and teardown are already synchronized 45 * on the shutdown lock, so no further synchronization is needed here 46 */ 47 48 static void setup() { 49 if (handler != null) return; 50 SignalHandler sh = new SignalHandler() { 51 public void handle(Signal sig) { 52 Shutdown.exit(sig.getNumber() + 0200); 53 } 54 }; 55 handler = sh; 56 // When -Xrs is specified the user is responsible for 57 // ensuring that shutdown hooks are run by calling 58 // System.exit() 59 try { 60 Signal.handle(new Signal("HUP"), sh); 61 } catch (IllegalArgumentException e) { 62 } 63 try { 64 Signal.handle(new Signal("INT"), sh); 65 } catch (IllegalArgumentException e) { 66 } 67 try { 68 Signal.handle(new Signal("TERM"), sh); 69 } catch (IllegalArgumentException e) { 70 } 71 } 72 73 static void teardown() { 74 /* The current sun.misc.Signal class does not support 75 * the cancellation of handlers 76 */ 77 } 78 79 } |