Package sun.misc

Examples of sun.misc.SignalHandler


     * 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;
View Full Code Here


    }

    public IRubyObject trap(final IRubyObject recv, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) {
        final JRubySignalHandler handler = new JRubySignalHandler(recv.getRuntime(), arg1, arg2, arg3.toString());
       
        final SignalHandler oldHandler;
        try {
            oldHandler = Signal.handle(new Signal(handler.signal), handler);
        } catch (Exception e) {
            throw recv.getRuntime().newArgumentError(e.getMessage());
        }
        if(oldHandler instanceof JRubySignalHandler) {
            return ((JRubySignalHandler)oldHandler).block;
        } else {
            return RubyProc.newProc(recv.getRuntime(), CallBlock.newCallClosure(recv, (RubyModule)recv,
                                                                                Arity.noArguments(), new BlockCallback(){
                                                                                        public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) {
                                                                                            oldHandler.handle(new Signal(handler.signal));
                                                                                            return recv.getRuntime().getNil();
                                                                                        }
                                                                                    }, recv.getRuntime().getCurrentContext()), Block.Type.NORMAL);
        }
    }
View Full Code Here

        this.interruptHook = interruptHook;
        this.console = console;
    }

    public void initInterrupt() throws IOException {
        SignalHandler handler = new SignalHandler() {
            @Override
            public void handle(Signal sig) {
                interruptHook.handleInterrupt(console);
            }
        };
View Full Code Here

        this.interruptHook = interruptHook;
        this.console = console;
    }

    public void initInterrupt() throws IOException {
        SignalHandler handler = new SignalHandler () {
            public void handle(Signal sig) {
                interruptHook.handleInterrupt(console);
            }
        };
        Signal.handle(new Signal("INT"), handler);
View Full Code Here

   *          When true the function will handle SIG_INT (Ctrl+C) by interrupting the processing and
   *          returning -1
   * @return 0 if ok
   */
  public int processLine(String line, boolean allowInterupting) {
    SignalHandler oldSignal = null;
    Signal interupSignal = null;

    if (allowInterupting) {
      // Remember all threads that were running at the time we started line processing.
      // Hook up the custom Ctrl+C handler while processing this line
      interupSignal = new Signal("INT");
      oldSignal = Signal.handle(interupSignal, new SignalHandler() {
        private final Thread cliThread = Thread.currentThread();
        private boolean interruptRequested;

        @Override
        public void handle(Signal signal) {
View Full Code Here

   *          When true the function will handle SIG_INT (Ctrl+C) by interrupting the processing and
   *          returning -1
   * @return
   */
  public int processLine(String line, boolean allowInterupting) {
    SignalHandler oldSignal = null;
    Signal interupSignal = null;

    if (allowInterupting) {
      // Remember all threads that were running at the time we started line processing.
      // Hook up the custom Ctrl+C handler while processing this line
      interupSignal = new Signal("INT");
      oldSignal = Signal.handle(interupSignal, new SignalHandler() {
        private final Thread cliThread = Thread.currentThread();
        private boolean interruptRequested;

        @Override
        public void handle(Signal signal) {
View Full Code Here

    if (!(new File(runtimeInfo.erl_bootstrap_ebindir)).exists() && !runtimeInfo.erl_bootstrap_ebindir.startsWith(EFile.RESOURCE_PREFIX)) {
      ERT.log.severe("No bootstrap classes at: "+runtimeInfo.erl_bootstrap_ebindir);
      throw new IllegalArgumentException("No bootstrap classes at: "+runtimeInfo.erl_bootstrap_ebindir);
    }
   
    @SuppressWarnings({})
    SignalHandler handler = new SignalHandler() {
     
      @Override
      public void handle(Signal arg0) {       
        ERT.print_all_stack_traces();
      }
View Full Code Here

    public IRubyObject trap(final Ruby runtime, BlockCallback blk, String sig) {
        return trap(runtime, new JRubySignalHandler(runtime, blk, sig));
    }

    private IRubyObject trap(final Ruby runtime, final JRubySignalHandler handler) {
        final SignalHandler oldHandler;
        final Signal signal;

        try {
            signal = new Signal(handler.signal);
        } catch (Throwable e) {
            return runtime.getNil();
        }

        try {
            oldHandler = Signal.handle(signal, handler);
        } catch (Exception e) {
            throw runtime.newArgumentError(e.getMessage());
        }

        BlockCallback callback = null;
        if (oldHandler instanceof JRubySignalHandler) {
            JRubySignalHandler jsHandler = (JRubySignalHandler) oldHandler;
            if (jsHandler.blockCallback != null) {
                callback = jsHandler.blockCallback;
            } else {
                return jsHandler.block;
            }
        }
        if (callback == null) {
            callback = new BlockCallback() {
                public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) {
                    oldHandler.handle(new Signal(handler.signal));
                    return runtime.getNil();
                }
            };
        }
        final RubyModule signalModule = runtime.getModule("Signal");
View Full Code Here

   *          When true the function will handle SIG_INT (Ctrl+C) by interrupting the processing and
   *          returning -1
   * @return 0 if ok
   */
  public int processLine(String line, boolean allowInterupting) {
    SignalHandler oldSignal = null;
    Signal interupSignal = null;

    if (allowInterupting) {
      // Remember all threads that were running at the time we started line processing.
      // Hook up the custom Ctrl+C handler while processing this line
      interupSignal = new Signal("INT");
      oldSignal = Signal.handle(interupSignal, new SignalHandler() {
        private final Thread cliThread = Thread.currentThread();
        private boolean interruptRequested;

        @Override
        public void handle(Signal signal) {
View Full Code Here

   *          When true the function will handle SIG_INT (Ctrl+C) by interrupting the processing and
   *          returning -1
   * @return
   */
  public int processLine(String line, boolean allowInterupting) {
    SignalHandler oldSignal = null;
    Signal interupSignal = null;

    if (allowInterupting) {
      // Remember all threads that were running at the time we started line processing.
      // Hook up the custom Ctrl+C handler while processing this line
      interupSignal = new Signal("INT");
      oldSignal = Signal.handle(interupSignal, new SignalHandler() {
        private final Thread cliThread = Thread.currentThread();
        private boolean interruptRequested;

        @Override
        public void handle(Signal signal) {
View Full Code Here

TOP

Related Classes of sun.misc.SignalHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.