Search in sources :

Example 1 with SignalHandler

use of sun.misc.SignalHandler in project neo4j by neo4j.

the class AdversarySignals method installAsSIGUSR2.

public synchronized void installAsSIGUSR2() {
    if (!installed) {
        Signal.handle(new Signal("USR2"), new SignalHandler() {

            @Override
            public void handle(Signal sig) {
                handleSignal();
            }
        });
        installed = true;
    }
}
Also used : Signal(sun.misc.Signal) SignalHandler(sun.misc.SignalHandler)

Example 2 with SignalHandler

use of sun.misc.SignalHandler in project neo4j by neo4j.

the class InterruptSignalHandler method install.

@Override
public Cancelable install(final Runnable action) {
    if (!actionRef.compareAndSet(null, action)) {
        throw new RuntimeException("An action has already been registered");
    }
    final SignalHandler oldHandler = Signal.handle(signal, this);
    final InterruptSignalHandler self = this;
    return new Cancelable() {

        @Override
        public void cancel() {
            SignalHandler handle = Signal.handle(signal, oldHandler);
            if (self != handle) {
                throw new RuntimeException("Error uninstalling ShellSignalHandler: " + "another handler interjected in the mean time");
            }
            if (!self.actionRef.compareAndSet(action, null)) {
                throw new RuntimeException("Popping a action that has not been pushed before");
            }
        }
    };
}
Also used : SignalHandler(sun.misc.SignalHandler) Cancelable(org.neo4j.helpers.Cancelable)

Example 3 with SignalHandler

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

the class SignalHandlers method installHandler.

/**
   * Adds the given signal handler to the existing ones.
   *
   * <p>Signal handlers are responsible to catch any exception if the following
   * handlers need to be executed when a handler throws an exception.
   *
   * @param signal The signal to handle.
   * @param signalHandler The handler to install.
   */
public void installHandler(Signal signal, final SignalHandler signalHandler) {
    final AtomicReference<SignalHandler> previousHandlerReference = new AtomicReference<>();
    previousHandlerReference.set(handlerInstaller.install(signal, new SignalHandler() {

        @Override
        public void handle(Signal signal) {
            signalHandler.handle(signal);
            SignalHandler previousHandler = previousHandlerReference.get();
            if (previousHandler != null) {
                previousHandler.handle(signal);
            }
        }
    }));
}
Also used : Signal(sun.misc.Signal) SignalHandler(sun.misc.SignalHandler) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 4 with SignalHandler

use of sun.misc.SignalHandler in project graal by oracle.

the class JLineSubstitutions method setupSigCont.

@Substitute
private void setupSigCont() {
    SignalHandler signalHandler = new SignalHandler() {

        @Override
        public void handle(Signal arg0) {
            /* Original implementation calls this code using reflection. */
            try {
                terminal.init();
                drawLine();
                flush();
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    };
    Signal.handle(new Signal("CONT"), signalHandler);
}
Also used : Signal(sun.misc.Signal) SignalHandler(sun.misc.SignalHandler) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 5 with SignalHandler

use of sun.misc.SignalHandler in project repseqio by repseqio.

the class Main method main.

public static void main(String[] args) throws Exception {
    Signal.handle(new Signal("PIPE"), new SignalHandler() {

        @Override
        public void handle(Signal signal) {
            System.exit(0);
        }
    });
    if (System.getProperty("localOnly") == null) {
        Path cachePath = Paths.get(System.getProperty("user.home"), ".repseqio", "cache");
        SequenceResolvers.initDefaultResolver(cachePath);
    }
    // Setting up main helper
    JCommanderBasedMain main = new JCommanderBasedMain("repseqio", new ListAction(), new FilterAction(), new MergeAction(), new CompileAction(), new GenerateClonesAction(), new NormalizeCloneAbundancesAction(), new ExportCloneSequencesAction(), new FastaAction(), new TsvAction(), new InferAnchorPointsAction(), new DebugAction(), new FormatAction(), new StatAction(), new FromFastaAction(), new FromPaddedFastaAction());
    main.setVersionInfoCallback(new Runnable() {

        @Override
        public void run() {
            VersionInfo milib = VersionInfo.getVersionInfoForArtifact("milib");
            VersionInfo repseqio = VersionInfo.getVersionInfoForArtifact("repseqio");
            StringBuilder builder = new StringBuilder();
            builder.append("RepSeq.IO.CLI v").append(repseqio.getVersion()).append(" (built ").append(repseqio.getTimestamp()).append("; rev=").append(repseqio.getRevision()).append("; branch=").append(repseqio.getBranch()).append("; host=").append(repseqio.getHost()).append(")").append("\n");
            builder.append("MiLib v").append(milib.getVersion()).append(" (rev=").append(milib.getRevision()).append("; branch=").append(milib.getBranch()).append(")").append("\n");
            builder.append("Built-in libraries:\n");
            VDJCLibraryRegistry reg = VDJCLibraryRegistry.createDefaultRegistry();
            reg.loadAllLibraries("default");
            for (VDJCLibrary lib : reg.getLoadedLibraries()) builder.append(lib.getLibraryId()).append("\n");
            System.out.print(builder.toString());
        }
    });
    main.main(args);
}
Also used : Signal(sun.misc.Signal) Path(java.nio.file.Path) VersionInfo(com.milaboratory.util.VersionInfo) JCommanderBasedMain(com.milaboratory.cli.JCommanderBasedMain) SignalHandler(sun.misc.SignalHandler) VDJCLibrary(io.repseq.core.VDJCLibrary) VDJCLibraryRegistry(io.repseq.core.VDJCLibraryRegistry)

Aggregations

SignalHandler (sun.misc.SignalHandler)19 Signal (sun.misc.Signal)14 ReporterConfiguration (com.uber.jaeger.Configuration.ReporterConfiguration)2 SamplerConfiguration (com.uber.jaeger.Configuration.SamplerConfiguration)2 ConstSampler (com.uber.jaeger.samplers.ConstSampler)2 ActiveSpan (io.opentracing.ActiveSpan)2 GlobalTracer (io.opentracing.util.GlobalTracer)2 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2 Paths (java.nio.file.Paths)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Nullable (javax.annotation.Nullable)2 ExceptionUtils (org.apache.commons.lang3.exception.ExceptionUtils)2 BatfishException (org.batfish.common.BatfishException)2 BatfishLogger (org.batfish.common.BatfishLogger)2