Register SIGINT signal handler with the ioloop to cancel the currently running cmdloop task.
340038
async def addSignalHandlers(self):
        '''
        
        '''

        def sigint():
            self.printf('<ctrl-c>')
            if self.cmdtask is not None:
                self.cmdtask.cancel()

        self.loop.add_signal_handler(signal.SIGINT, sigint)
730473
function signalKill(childProcess, callback) {
  childProcess.emit('signalKill');
  if (IS_WINDOWS) {
    const taskkill = spawn('taskkill', ['/F', '/T', '/PID', childProcess.pid]);
    taskkill.on('exit', (exitStatus) => {
      if (exitStatus) {
        return callback(
          new Error(`Unable to forcefully terminate process ${childProcess.pid}`)
        );
      }
      callback();
    });
  } else {
    childProcess.kill('SIGKILL');
    process.nextTick(callback);
  }
}
933021
protected function sigquit()
    {
        if (Daemon::$config->logsignals->value) {
            $this->log('Caught SIGQUIT.');
        }

        $this->signalToChildren(SIGQUIT);
        $this->shutdown(SIGQUIT);
    }
598584
async def shutdown(sig, loop):
    """"""
    logging.info(f'Received exit signal {sig.name}...')
    tasks = [task for task in asyncio.Task.all_tasks() if task is not
             asyncio.tasks.Task.current_task()]

    for task in tasks:
        logging.debug(f'Cancelling task: {task}')
        task.cancel()

    results = await asyncio.gather(*tasks, return_exceptions=True)
    logging.debug(f'Done awaiting cancelled tasks, results: {results}')

    loop.stop()
    logging.info('Shutdown complete.')
1360325
def signal_catcher(callback):
    """"""
    def _catch_exit_signal(sig_num, _frame):
        print('Received signal {:d} invoking callback...'.format(sig_num))
        callback()

    signal.signal(signal.SIGINT, _catch_exit_signal)
    signal.signal(signal.SIGQUIT, _catch_exit_signal)
    signal.signal(signal.SIGTERM, _catch_exit_signal)
    yield
447835
def raise_sigint():
    
    if hasattr(signal, 'CTRL_C_EVENT'):
        # windows. Need CTRL_C_EVENT to raise the signal in the whole process group
        os.kill(os.getpid(), signal.CTRL_C_EVENT)
    else:
        # unix.
        pgid = os.getpgid(os.getpid())
        if pgid == 1:
            os.kill(os.getpid(), signal.SIGINT)
        else:
            os.killpg(os.getpgid(os.getpid()), signal.SIGINT)
1340067
def stop():
    
    global global_server
    if global_server is not None:
        ioloop = global_server.ioloop
        def stop_ioloop():
            ioloop.stop()
            ioloop.close()
        global_server.ioloop.add_callback(stop_ioloop)
        global_server = None
904456
def signal(sig)
      sig = sig.to_i if sig.to_i != 0
      applog(self, :info, "#{self.name} sending signal '#{sig}' to pid #{self.pid}")
      ::Process.kill(sig, self.pid) rescue nil
    end
718717
def cli(env, identifier, immediate, comment, reason):
    """"""

    mgr = SoftLayer.HardwareManager(env.client)
    hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')

    if not (env.skip_confirmations or formatting.no_going_back(hw_id)):
        raise exceptions.CLIAbort('Aborted')

    mgr.cancel_hardware(hw_id, reason, comment, immediate)
1157376
def stop(self, signal=None):
        
        signal = signal or self.int_signal
        self.out.log("Cleaning up local Heroku process...")
        if self._process is None:
            self.out.log("No local Heroku process was running.")
            return

        try:
            os.killpg(os.getpgid(self._process.pid), signal)
            self.out.log("Local Heroku process terminated.")
        except OSError:
            self.out.log("Local Heroku was already terminated.")
            self.out.log(traceback.format_exc())
        finally:
            self._process = None
849176
def clear_signal_handlers(self):
        '''

        '''
        signal.signal(signal.SIGABRT, self.old_sigabrt)
        signal.signal(signal.SIGINT, self.old_sigint)
        signal.signal(signal.SIGPIPE, self.old_sigpipe)
        signal.signal(signal.SIGTERM, self.old_sigterm)
1152401
def finish(self):
        
        super(InterruptibleMixin, self).finish()
        signal(SIGINT, self.original_handler)
77196
def event_listen_stop(self):
		''''''
		self._loop_stop = True
		c.pa.mainloop_wakeup(self._loop)
901821
public static void registerJStormSignalHandler() {
        if (!OSInfo.isLinux()) {
            LOG.info("Skip register signal for current OS");
            return;
        }

        JStormSignalHandler instance = JStormSignalHandler.getInstance();
        int[] signals = {
                1, //SIGHUP
                2, //SIGINT
                //3, //Signal already used by VM or OS: SIGQUIT
                //4, //Signal already used by VM or OS: SIGILL
                5, //SIGTRAP
                6, //SIGABRT
                7, // SIGBUS
                //8, //Signal already used by VM or OS: SIGFPE
                //10, //Signal already used by VM or OS: SIGUSR1
                //11, Signal already used by VM or OS: SIGSEGV
                12, //SIGUSER2
                14, //SIGALM
                16, //SIGSTKFLT
        };


        for (int signal : signals) {
            instance.registerSignal(signal, null, true);
        }

    }
841150
def cancel(self):
        """"""
        if self.OBSERVE_UPDATES:
            self.detach()
        self.ioloop.add_callback(self.cancel_timeouts)
712177
def handle_sigint(self, signum, frame):
        
        self.finish()
        self.original_handler(signum, frame)
1046017
def abort_io(self, iocb, err):
        """"""
        if _debug: IOQController._debug("abort_io %r %r", iocb, err)

        # normal abort
        IOController.abort_io(self, iocb, err)

        # check to see if it is completing the active one
        if iocb is not self.active_iocb:
            if _debug: IOQController._debug("    - not current iocb")
            return

        # no longer an active iocb
        self.active_iocb = None

        # change our state
        self.state = CTRL_IDLE
        _statelog.debug("%s %s %s" % (_strftime(), self.name, "idle"))

        # look for more to do
        deferred(IOQController._trigger, self)