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 } | 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 } catch (IllegalArgumentException e) { 59 // When -Xrs is specified the user is responsible for 60 // ensuring that shutdown hooks are run by calling 61 // System.exit() 62 } 63 try { 64 Signal.handle(new Signal("INT"), sh); 65 } catch (IllegalArgumentException e) { 66 // When -Xrs is specified the user is responsible for 67 // ensuring that shutdown hooks are run by calling 68 // System.exit() 69 } 70 try { 71 Signal.handle(new Signal("TERM"), sh); 72 } catch (IllegalArgumentException e) { 73 // When -Xrs is specified the user is responsible for 74 // ensuring that shutdown hooks are run by calling 75 // System.exit() 76 } 77 } 78 79 static void teardown() { 80 /* The current sun.misc.Signal class does not support 81 * the cancellation of handlers 82 */ 83 } 84 85 } |