Search in sources :

Example 11 with SignalHandler

use of sun.misc.SignalHandler in project bazel by bazelbuild.

the class SignalHandlersTest method testHandlersCanBeChained.

@Test
public void testHandlersCanBeChained() {
    SignalHandler handler1 = Mockito.mock(SignalHandler.class);
    SignalHandler handler2 = Mockito.mock(SignalHandler.class);
    signalHandlers.installHandler(TERM_SIGNAL, handler1);
    signalHandlers.installHandler(TERM_SIGNAL, handler2);
    fakeSignalInstaller.sendSignal();
    Mockito.verify(handler1).handle(Mockito.eq(TERM_SIGNAL));
    Mockito.verify(handler2).handle(Mockito.eq(TERM_SIGNAL));
}
Also used : SignalHandler(sun.misc.SignalHandler) Test(org.junit.Test)

Example 12 with SignalHandler

use of sun.misc.SignalHandler in project orientdb by orientechnologies.

the class OSignalHandler method listenTo.

public void listenTo(final String name, final SignalHandler iListener) {
    Signal signal = new Signal(name);
    SignalHandler redefinedHandler = Signal.handle(signal, iListener);
    if (redefinedHandler != null) {
        redefinedHandlers.put(signal, redefinedHandler);
    }
}
Also used : Signal(sun.misc.Signal) SignalHandler(sun.misc.SignalHandler)

Example 13 with SignalHandler

use of sun.misc.SignalHandler in project jdk8u_jdk by JetBrains.

the class Terminator method setup.

/* Invocations of setup and teardown are already synchronized
     * on the shutdown lock, so no further synchronization is needed here
     */
static void setup() {
    if (handler != null)
        return;
    SignalHandler sh = new SignalHandler() {

        public void handle(Signal sig) {
            Shutdown.exit(sig.getNumber() + 0200);
        }
    };
    handler = sh;
    // System.exit()
    try {
        Signal.handle(new Signal("INT"), sh);
    } catch (IllegalArgumentException e) {
    }
    try {
        Signal.handle(new Signal("TERM"), sh);
    } catch (IllegalArgumentException e) {
    }
}
Also used : Signal(sun.misc.Signal) SignalHandler(sun.misc.SignalHandler)

Aggregations

SignalHandler (sun.misc.SignalHandler)13 Signal (sun.misc.Signal)9 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Test (org.junit.Test)2 DTConfiguration (com.datatorrent.stram.client.DTConfiguration)1 LogicalPlanConfiguration (com.datatorrent.stram.plan.logical.LogicalPlanConfiguration)1 TTYConsoleReader (com.orientechnologies.common.console.TTYConsoleReader)1 OSystemException (com.orientechnologies.common.exception.OSystemException)1 OIOException (com.orientechnologies.common.io.OIOException)1 OSignalHandler (com.orientechnologies.orient.core.OSignalHandler)1 OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)1 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)1 ORetryQueryException (com.orientechnologies.orient.core.exception.ORetryQueryException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)1 BasicParser (org.apache.commons.cli.BasicParser)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 Options (org.apache.commons.cli.Options)1