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:
SignalHandler handler = new SignalHandler () {
public void handle(Signal sig) {
... // handle SIGINT
}
};
Signal.handle(new Signal("INT"), handler);
sun.misc.SignalHandler
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static class |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: whether twoSignal objects are equal.the object to compare with. other)Overrides java. Compares the equality of two |
| public String | |
| public int | |
| public static synchronized SignalHandler | Returns: the old handlera signal sig, SignalHandler the handler to be registered with the given signal. handler)Registers a signal handler. |
| public int | Returns: a hash code value for this object.Overrides java. Returns a hashcode for this Signal. |
| public static void | |
| public String | Returns: a string representation of the signalOverrides java. Returns a string representation of this signal. |
| iSignal | back to summary |
|---|---|
| private final Signal iSignal | |
| Signal | back to summary |
|---|---|
| public Signal(String name) Constructs a signal from its name.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Compares the equality of two
| |
| 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 SignalHandler handle(Signal sig, SignalHandler handler) throws IllegalArgumentException Registers a signal handler.
| |
| 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.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this signal. For example, "SIGINT"
for an object constructed using
| |
| Modifier and Type | Field and Description |
|---|---|
| private final SignalHandler | |
| private final Signal |
| Access | Constructor and Description |
|---|---|
| private |
| handler | back to summary |
|---|---|
| private final SignalHandler handler | |
| signal | back to summary |
|---|---|
| private final Signal signal | |
| InternalMiscHandler | back to summary |
|---|---|
| private InternalMiscHandler(Signal signal, SignalHandler handler) | |
| handle | back to summary |
|---|---|
| public void handle(Signal ignore) Implements jdk. Doc from jdk. Handle the given signal
| |
| of | back to summary |
|---|---|
| pack-priv static Signal. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Signal. | |
| private final Signal |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| pack-priv static SignalHandler | |
| public String |
| iHandler | back to summary |
|---|---|
| private final Signal. | |
| iSignal | back to summary |
|---|---|
| private final Signal iSignal | |
| SunMiscHandler | back to summary |
|---|---|
| pack-priv SunMiscHandler(Signal iSignal, Signal. | |
| handle | back to summary |
|---|---|
| public void handle(Signal sig) Implements sun. Doc from sun. Handle the given signal
| |
| of | back to summary |
|---|---|
| pack-priv static SignalHandler of(Signal signal, 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- | |