added experimental Signals class
authoradam <adam@megacz.com>
Thu, 30 Jun 2005 07:09:48 +0000 (07:09 +0000)
committeradam <adam@megacz.com>
Thu, 30 Jun 2005 07:09:48 +0000 (07:09 +0000)
darcs-hash:20050630070948-5007d-1aeec8334f509608c93e2292ab18276abc07b20f.gz

src/org/ibex/util/Signals.java [new file with mode: 0644]

diff --git a/src/org/ibex/util/Signals.java b/src/org/ibex/util/Signals.java
new file mode 100644 (file)
index 0000000..7ee5b93
--- /dev/null
@@ -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) { }
+        }
+    }
+}