Package sun.misc

Examples of sun.misc.Signal


    Shutdown.exit(sig.getNumber() + 0200);
      }
  };
  handler = sh;
        try {
            Signal.handle(new Signal("INT"), sh);
            Signal.handle(new Signal("TERM"), sh);
        } catch (IllegalArgumentException e) {
            // When -Xrs is specified the user is responsible for
            // ensuring that shutdown hooks are run by calling
            // System.exit()
        }
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

                        .callMethod(context, "raise", e.getException());
                } catch(Exception ignored) {}
            } catch (MainExitException mee) {
                runtime.getThreadService().getMainThread().kill();
            } finally {
                Signal.handle(new Signal(this.signal), this);
            }
        }
View Full Code Here

   */
  public IrqHandler(String name, Interrupted handler) throws IOException {
    this.handler = handler;
    this.name = name;
    try {
      Signal.handle(new Signal(name), this);
    } catch (IllegalArgumentException e) {
      throw new IOException(
        "Could not set handler for signal \"" + name + "\"."
        + "This can happen if the JVM has the -Xrs set.",
        e);
View Full Code Here

            @Override
            public void handle(Signal sig) {
                interruptHook.handleInterrupt(console);
            }
        };
        original = Signal.handle(new Signal("INT"), handler);
    }
View Full Code Here

        };
        original = Signal.handle(new Signal("INT"), handler);
    }

    public void removeInterrupt() {
        Signal.handle(new Signal("INT"), original);
    }
View Full Code Here

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

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

    {
        this(parseConfig(configurationURL));
        _configFile = configurationURL;
        try
        {
            Signal sig = new sun.misc.Signal("HUP");
            sun.misc.Signal.handle(sig, this);
        }
        catch (Exception e)
        {
            _logger.info("Signal HUP not supported for OS: " + System.getProperty("os.name"));
View Full Code Here

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

TOP

Related Classes of sun.misc.Signal

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.