Send the signal *signum* to the child.

        On Windows, SIGTERM, SIGKILL and SIGINT are emulated using
        TerminateProcess(). This will cause the child to exit unconditionally
        with status 1. No other signals can be sent on Windows.
337652
def send_signal(self, signum):
        
        if self._process is None:
            raise RuntimeError('no child process')
        self._process.kill(signum)
1335398
public static function signal_handler($signo) {
        // Note: There is no need to manually call the shutdown handler.
        // The fact that we are calling exit() in this script means that the standard shutdown handling is performed
        // anyway.
        switch ($signo) {
            case SIGTERM:
                // Replicate native behaviour.
                echo "Terminated: {$signo}\n";

                // The standard exit code for SIGTERM is 143.
                $exitcode = 143;
                break;
            case SIGINT:
                // Replicate native behaviour.
                echo "\n";

                // The standard exit code for SIGINT (Ctrl+C) is 130.
                $exitcode = 130;
                break;
            default:
                // The signal handler was called with a signal it was not expecting.
                // We should exit and complain.
                echo "Warning: \core_shutdown_manager::signal_handler() was called with an unexpected signal ({$signo}).\n";
                $exitcode = 1;
        }

        exit ($exitcode);
    }
1198580
def _register_sigterm(self):
        

        _handler = lambda signo, frame: self.shutdown()
        signal.signal(signal.SIGTERM, _handler)
74815
def process_kill(pid, sig=None):
    
    sig = sig or signal.SIGTERM
    os.kill(pid, sig)
1304205
def suppress_interrupt():
    
    interrupted = False

    def sigint_handler(signum, frame):
        nonlocal interrupted
        interrupted = True
    
    s = signal.signal(signal.SIGINT, sigint_handler)
    try:
        yield None
    finally:
        signal.signal(signal.SIGINT, s)
    if interrupted:
        raise KeyboardInterrupt()
417396
def raiseMasterKilled(signum, _stack):
    
    # Disable further CTRL-C to allow tasks revocation when Celery is used
    if OQ_DISTRIBUTE.startswith('celery'):
        signal.signal(signal.SIGINT, inhibitSigInt)

    msg = 'Received a signal %d' % signum
    if signum in (signal.SIGTERM, signal.SIGINT):
        msg = 'The openquake master process was killed manually'

    # kill the calculation only if os.getppid() != _PPID, i.e. the controlling
    # terminal died; in the workers, do nothing
    # NB: there is no SIGHUP on Windows
    if hasattr(signal, 'SIGHUP'):
        if signum == signal.SIGHUP:
            if os.getppid() == _PPID:
                return
            else:
                msg = 'The openquake master lost its controlling terminal'

    raise MasterKilled(msg)
355171
public function signalHandler($sigNo)
    {
        switch ($sigNo) {
            case SIGINT: // Ctrl + C
            case SIGTERM:
                $sigText = $sigNo === SIGINT ? 'SIGINT(Ctrl+C)' : 'SIGTERM';
                $this->log("Shutting down($sigNo:$sigText)...", ProcessLogger::PROC_INFO);
                $this->stopWork();
                break;
            default:
                // handle all other signals
        }
    }
361172
def handle_signal(self, sig, frame):
        """"""
        if sig in [signal.SIGINT]:
            log.warning("Ctrl-C pressed, shutting down...")
        if sig in [signal.SIGTERM]:
            log.warning("SIGTERM received, shutting down...")
        self.cleanup()
        sys.exit(-sig)
98735
def set_stop_handler(self):
        
        signal.signal(signal.SIGTERM, self.graceful_stop)
        signal.signal(signal.SIGABRT, self.graceful_stop)
        signal.signal(signal.SIGINT, self.graceful_stop)
1146129
def terminate(self, unique_id, configs=None):
    
    self._send_signal(unique_id, signal.SIGTERM, configs)
1008016
def maybe_send_signal(self, signum, include_pgrp=True):
    
    remote_pid = self._maybe_last_pid()
    if remote_pid is not None:
      safe_kill(remote_pid, signum)
    if include_pgrp:
      remote_pgrp = self._maybe_last_pgrp()
      if remote_pgrp:
        safe_kill(remote_pgrp, signum)
811142
def sendstop(self):
        '''
        
        '''
        if not self.is_started:
            raise EasyProcessError(self, 'process was not started!')

        log.debug('stopping process (pid=%s cmd="%s")', self.pid, self.cmd)
        if self.popen:
            if self.is_alive():
                log.debug('process is active -> sending SIGTERM')

                try:
                    try:
                        self.popen.terminate()
                    except AttributeError:
                        os.kill(self.popen.pid, signal.SIGKILL)
                except OSError as oserror:
                    log.debug('exception in terminate:%s', oserror)

            else:
                log.debug('process was already stopped')
        else:
            log.debug('process was not started')

        return self
1076208
def terminate(self):
        
        logger.info('Sending SIGTERM to task {0}'.format(self.name))
        if hasattr(self, 'remote_client') and self.remote_client is not None:
            self.terminate_sent = True
            self.remote_client.close()
            return
        if not self.process:
            raise DagobahError('task does not have a running process')
        self.terminate_sent = True
        self.process.terminate()
634397
def terminate(self, signal_chain=KILL_CHAIN, kill_wait=KILL_WAIT_SEC, purge=True):
    """"""
    alive = self.is_alive()
    if alive:
      logger.debug('terminating {}'.format(self._name))
      for signal_type in signal_chain:
        pid = self.pid
        try:
          logger.debug('sending signal {} to pid {}'.format(signal_type, pid))
          self._kill(signal_type)
        except OSError as e:
          logger.warning('caught OSError({e!s}) during attempt to kill -{signal} {pid}!'
                         .format(e=e, signal=signal_type, pid=pid))

        # Wait up to kill_wait seconds to terminate or move onto the next signal.
        try:
          if self._deadline_until(self.is_dead, 'daemon to exit', timeout=kill_wait):
            alive = False
            logger.debug('successfully terminated pid {}'.format(pid))
            break
        except self.Timeout:
          # Loop to the next kill signal on timeout.
          pass

    if alive:
      raise ProcessManager.NonResponsiveProcess('failed to kill pid {pid} with signals {chain}'
                                      .format(pid=self.pid, chain=signal_chain))

    if purge:
      self.purge_metadata(force=True)
483622
protected function handleSignals(): void
    {
        foreach ([SIGTERM, SIGQUIT, SIGABRT, SIGINT] as $signal) {
            pcntl_signal($signal, function ($signal) {
                $this->terminate($signal);
            });
        }
    }
1079823
def signal_terminate(on_terminate):
    """"""
    for i in [signal.SIGINT, signal.SIGQUIT, signal.SIGUSR1, signal.SIGUSR2, signal.SIGTERM]:
        signal.signal(i, on_terminate)
856929
def signal_pid(pid, signum):
    
    try:
        os.kill(pid, signum)
        return True
    except OSError, e:
        # see man 2 kill
        if e.errno == errno.EPERM:
            # exists but belongs to a different user
            return True
        if e.errno == errno.ESRCH:
            # pid does not exist
            return False
        raise