Save This Page
Home » openjdk-7 » sun » misc » [javadoc | source]
public final class: Signal [javadoc | source]
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);
 public Signal(String name) 
    Constructs a signal from its name.
    name - the name of the signal.
    IllegalArgumentException - unknown signal
    Also see:
    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").