APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.misc

public final Class Signal

extends Object
Class Inheritance
Imports
java.util.Hashtable, .Objects

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:

Signal.Handler handler = new Signal.Handler () {
    public void handle(Signal sig) {
      ... // handle SIGINT
    }
};
Signal.handle(new Signal("INT"), handler);
Since
9

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Signal.Handler

This is the signal handler interface expected in Signal.handle.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Hashtable<Signal, Signal.Handler>
private String
private int
private static final Hashtable<Integer, Signal>

Constructor Summary

AccessConstructor and Description
public
Signal(String
the name of the signal.
name
)

Constructs a signal from its name.

Method Summary

Modifier and TypeMethod and Description
private static void
dispatch(final int number)

public boolean

Returns:

whether two Signal objects are equal.
equals
(Object
the object to compare with.
obj
)

Overrides java.lang.Object.equals.

Compares the equality of two Signal objects.

private static native int
public String

Returns:

the name of the signal.
getName
()

Returns the signal name.

public int
public static synchronized Signal.Handler

Returns:

the old handler
handle
(Signal
a signal
sig
,
Signal.Handler
the handler to be registered with the given signal.
handler
)

Registers a signal handler.

private static native long
handle0(int sig, long nativeH)

public int

Returns:

a hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this Signal.

public static void
raise(Signal
a signal
sig
)

Raises a signal in the current process.

private static native void
raise0(int sig)

public String

Returns:

a string representation of the signal
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this signal.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

handlersback to summary
private static final Hashtable<Signal, Signal.Handler> handlers
nameback to summary
private String name
numberback to summary
private int number
signalsback to summary
private static final Hashtable<Integer, Signal> signals

Constructor Detail

Signalback to summary
public Signal(String name)

Constructs a signal from its name.

Parameters
name:String

the name of the signal.

Exceptions
IllegalArgumentException:
unknown signal
See Also
jdk.internal.misc.Signal#getName()

Method Detail

dispatchback to summary
private static void dispatch(final int number)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares the equality of two Signal objects.

Parameters
obj:Object

the object to compare with.

Returns:boolean

whether two Signal objects are equal.

findSignal0back to summary
private static native int findSignal0(String sigName)
getNameback to summary
public String getName()

Returns the signal name.

Returns:String

the name of the signal.

See Also
jdk.internal.misc.Signal#Signal(String name)
getNumberback to summary
public int getNumber()
handleback to summary
public static synchronized Signal.Handler handle(Signal sig, Signal.Handler handler) throws IllegalArgumentException

Registers a signal handler.

Parameters
sig:Signal

a signal

handler:Signal.Handler

the handler to be registered with the given signal.

Returns:Signal.Handler

the old handler

Exceptions
IllegalArgumentException:
the signal is in use by the VM
See Also
jdk.internal.misc.Signal#raise(Signal sig), jdk.internal.misc.Signal.Handler, jdk.internal.misc.Signal.Handler#SIG_DFL, jdk.internal.misc.Signal.Handler#SIG_IGN
handle0back to summary
private static native long handle0(int sig, long nativeH)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this Signal.

Returns:int

a hash code value for this object.

raiseback to summary
public static void raise(Signal sig) throws IllegalArgumentException

Raises a signal in the current process.

Parameters
sig:Signal

a signal

See Also
jdk.internal.misc.Signal#handle(Signal sig, Signal.Handler handler)
raise0back to summary
private static native void raise0(int sig)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this signal. For example, "SIGINT" for an object constructed using new Signal ("INT").

Returns:String

a string representation of the signal

jdk.internal.misc back to summary

public Interface Signal.Handler

Known Direct Implementers
jdk.internal.misc.Signal.NativeHandler

This is the signal handler interface expected in Signal.handle.

Field Summary

Modifier and TypeField and Description
public static final Signal.Handler
SIG_DFL

The default signal handler

public static final Signal.Handler
SIG_IGN

Ignore the signal

Method Summary

Modifier and TypeMethod and Description
public void
handle(Signal
a signal object
sig
)

Handle the given signal

Field Detail

SIG_DFLback to summary
public static final Signal.Handler SIG_DFL

The default signal handler

SIG_IGNback to summary
public static final Signal.Handler SIG_IGN

Ignore the signal

Method Detail

handleback to summary
public void handle(Signal sig)

Handle the given signal

Parameters
sig:Signal

a signal object

jdk.internal.misc back to summary

pack-priv final Class Signal.NativeHandler

extends Object
implements Handler
Class Inheritance
All Implemented Interfaces
jdk.internal.misc.Signal.Handler

Field Summary

Modifier and TypeField and Description
private final long

Constructor Summary

AccessConstructor and Description
pack-priv
NativeHandler(long handler)

Method Summary

Modifier and TypeMethod and Description
pack-priv long
public void
handle(Signal sig)

Implements jdk.internal.misc.Signal.Handler.handle.

Handle the given signal

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

handlerback to summary
private final long handler

Constructor Detail

NativeHandlerback to summary
pack-priv NativeHandler(long handler)

Method Detail

getHandlerback to summary
pack-priv long getHandler()
handleback to summary
public void handle(Signal sig)

Implements jdk.internal.misc.Signal.Handler.handle.

Doc from jdk.internal.misc.Signal.Handler.handle.

Handle the given signal

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.