From: adam Date: Thu, 30 Jun 2005 07:09:48 +0000 (+0000) Subject: added experimental Signals class X-Git-Url: http://git.megacz.com/?p=org.ibex.util.git;a=commitdiff_plain;h=29e267c8c02d6326ba551d6e56340b57dba2816b added experimental Signals class darcs-hash:20050630070948-5007d-1aeec8334f509608c93e2292ab18276abc07b20f.gz --- diff --git a/src/org/ibex/util/Signals.java b/src/org/ibex/util/Signals.java new file mode 100644 index 0000000..7ee5b93 --- /dev/null +++ b/src/org/ibex/util/Signals.java @@ -0,0 +1,31 @@ +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the Apache Public Source License 2.0 ("the License"). +// You may not use this file except in compliance with the License. + +package org.ibex.util; +import java.io.*; +import sun.misc.*; + +/** + * This class uses the highly-proprietary sun.misc.Signal class to + * let the JVM ignore SIGHUP. This is useful when you want to start + * a JVM and leave it running after you've logged out. + */ +public class Signals { + public static void inhibitSigHUP() { + Signal.handle(new Signal("HUP"), new SignalHandler () { + public void handle(Signal sig) { + System.out.println("got SIGHUP; ignoring"); + } + }); + } + + + public static void main(String[] s) { + inhibitSigHUP(); + for(;;) { + System.out.println("hi"); + try { Thread.sleep(1000); } catch (Exception e) { } + } + } +}