Signal.handle
function raises an IllegalArgumentException if such an attempt
is made.
Signal.handle is called, the VM internally registers a
special C signal handler. There is no way to force the Java signal handler
to run synchronously before the C signal handler returns. Instead, when the
VM receives a signal, the special C signal handler creates a new thread
(at priority Thread.MAX_PRIORITY) to
run the registered Java signal handler. The C signal handler immediately
returns. Note that because the Java signal handler runs in a newly created
thread, it may not actually be executed until some time after the C signal
handler returns.
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:
Signal.Handler handler = new Signal.Handler () {
public void handle(Signal sig) {
... // handle SIGINT
}
};
Signal.handle(new Signal("INT"), handler);
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Signal.
This is the signal handler interface expected in |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Hashtable | |
| private String | |
| private int | |
| private static final Hashtable |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| public boolean | Returns: whether twoSignal objects are equal.the object to compare with. obj)Overrides java. Compares the equality of two |
| private static native int | |
| public String | |
| public int | |
| public static synchronized Signal. | |
| private static native long | |
| public int | Returns: a hash code value for this object.Overrides java. Returns a hashcode for this Signal. |
| public static void | |
| private static native void | |
| public String | Returns: a string representation of the signalOverrides java. Returns a string representation of this signal. |
| handlers | back to summary |
|---|---|
| private static final Hashtable<Signal, Signal. | |
| name | back to summary |
|---|---|
| private String name | |
| number | back to summary |
|---|---|
| private int number | |
| signals | back to summary |
|---|---|
| private static final Hashtable<Integer, Signal> signals | |
| Signal | back to summary |
|---|---|
| public Signal(String name) Constructs a signal from its name.
| |
| dispatch | back to summary |
|---|---|
| private static void dispatch(final int number) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Compares the equality of two
| |
| findSignal0 | back to summary |
|---|---|
| private static native int findSignal0(String sigName) | |
| getName | back to summary |
|---|---|
| public String getName() Returns the signal name.
| |
| getNumber | back to summary |
|---|---|
| public int getNumber() | |
| handle | back to summary |
|---|---|
| public static synchronized Signal. Registers a signal handler.
| |
| handle0 | back to summary |
|---|---|
| private static native long handle0(int sig, long nativeH) | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hashcode for this Signal.
| |
| raise | back to summary |
|---|---|
| public static void raise(Signal sig) throws IllegalArgumentException Raises a signal in the current process.
| |
| raise0 | back to summary |
|---|---|
| private static native void raise0(int sig) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this signal. For example, "SIGINT"
for an object constructed using
| |
Signal.handle.
| Modifier and Type | Field and Description |
|---|---|
| public static final Signal. | SIG_DFL
The default signal handler |
| public static final Signal. | SIG_IGN
Ignore the signal |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| SIG_DFL | back to summary |
|---|---|
| public static final Signal. The default signal handler | |
| SIG_IGN | back to summary |
|---|---|
| public static final Signal. Ignore the signal | |
| handle | back to summary |
|---|---|
| public void handle(Signal sig) Handle the given signal
| |
| Modifier and Type | Field and Description |
|---|---|
| private final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv long | |
| public void | |
| public String |
| handler | back to summary |
|---|---|
| private final long handler | |
| NativeHandler | back to summary |
|---|---|
| pack-priv NativeHandler(long handler) | |
| getHandler | back to summary |
|---|---|
| pack-priv long getHandler() | |
| handle | back to summary |
|---|---|
| public void handle(Signal sig) Implements jdk. Doc from jdk. Handle the given signal | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |