Save This Page
Home » openjdk-7 » sun » misc » [javadoc | source]
sun.misc
public final class: Signal [javadoc | source]
java.lang.Object
   sun.misc.Signal
This class provides ANSI/ISO C signal support. A Java program can register signal handlers for the current process. There are two restrictions:

Signal objects are created based on their names. For example:

new Signal("INT");
constructs a signal object corresponding to SIGINT, which is typically produced when the user presses Ctrl-C at the command line. The Signal constructor throws IllegalArgumentException when it is passed an unknown signal.

This is an example of how Java code handles SIGINT:

SignalHandler handler = new SignalHandler () {
    public void handle(Signal sig) {
      ... // handle SIGINT
    }
};
Signal.handle(new Signal("INT"), handler);
Constructor:
 public Signal(String name) 
    Constructs a signal from its name.
    Parameters:
    name - the name of the signal.
    Throws:
    IllegalArgumentException - unknown signal
    Also see:
    sun.misc.Signal#getName()
    exception: IllegalArgumentException - unknown signal
Method from sun.misc.Signal Summary:
equals,   getName,   getNumber,   handle,   hashCode,   raise,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.misc.Signal Detail:
 public boolean equals(Object other) 
    Compares the equality of two Signal objects.
 public String getName() 
    Returns the signal name.
 public int getNumber() 
 public static synchronized SignalHandler handle(Signal sig,
    SignalHandler handler) throws IllegalArgumentException 
    Registers a signal handler.
 public int hashCode() 
    Returns a hashcode for this Signal.
 public static  void raise(Signal sig) throws IllegalArgumentException 
    Raises a signal in the current process.
 public String toString() 
    Returns a string representation of this signal. For example, "SIGINT" for an object constructed using new Signal ("INT").