Handles signals
@param int $sigNo
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
        }
    }
971136
def _handle_signal_gracefully(cls, signum, signame, traceback_lines):
    """"""
    # Extract the stack, and format an entry to be written to the exception log.
    formatted_traceback = cls._format_traceback(traceback_lines=traceback_lines,
                                                should_print_backtrace=True)
    signal_error_log_entry = cls._CATCHABLE_SIGNAL_ERROR_LOG_FORMAT.format(
      signum=signum,
      signame=signame,
      formatted_traceback=formatted_traceback)
    # TODO: determine the appropriate signal-safe behavior here (to avoid writing to our file
    # descriptors re-entrantly, which raises an IOError).
    # This method catches any exceptions raised within it.
    cls.log_exception(signal_error_log_entry)

    # Create a potentially-abbreviated traceback for the terminal or other interactive stream.
    formatted_traceback_for_terminal = cls._format_traceback(
      traceback_lines=traceback_lines,
      should_print_backtrace=cls._should_print_backtrace_to_terminal)
    terminal_log_entry = cls._CATCHABLE_SIGNAL_ERROR_LOG_FORMAT.format(
      signum=signum,
      signame=signame,
      formatted_traceback=formatted_traceback_for_terminal)
    # Exit, printing the output to the terminal.
    cls._exit_with_failure(terminal_log_entry)
220018
public function onSignal($nSignal)
	{
		switch ($nSignal) {
			case SIGTERM:
			case SIGQUIT:
			case SIGINT:
				if (($nPid = posix_getpid()) != $this->_nParentPid) {
					$this->_log("INFO: Child $nPid received signal #{$nSignal}, shutdown...");
					$this->_nRunningProcesses--;
					exit(0);
				}
				break;
			default:
				$this->_log("INFO: Ignored signal #{$nSignal}.");
				break;
		}
	}
707893
public static function signalHandler($signal)
    {
        switch ($signal) {
            // Stop.
            case SIGINT:
                self::stopAll();
                break;
            // Reload.
            case SIGUSR1:
                self::$_pidsToRestart = self::getAllWorkerPids();
                self::reload();
                break;
            // Show status.
            case SIGUSR2:
                self::writeStatisticsToStatusFile();
                break;
        }
    }
720901
public function signalReceived($signal)
	{
		if (!$this->tryCall($this->formatSignalMethod($signal), $this->params)) {
			$class = get_class($this);
			throw new BadSignalException("There is no handler for signal '$signal' in class $class.");
		}
	}
1033813
def signal_handler(self, signum, frame):
        
        self.print_exit()
        print("\n(Terminated with signal %d)\n" % (signum))
        sys.exit(0)
670145
def _handle_sigint(self, signum: int, frame: Any) -> None:
        """"""
        logger.warning("Catched SIGINT")
        self.shutdown()
984920
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\SectionService\AssignSectionSignal) {
            return;
        }

        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($signal->contentId);
        $this->searchHandler->indexContent(
            $this->persistenceHandler->contentHandler()->load($contentInfo->id, $contentInfo->currentVersionNo)
        );
    }
334700
def _signal_handler(self, signum, frame):
        
        if self._options.config:
            with open(self._options.config, "w") as cfg:
                yaml.dump(self._home_assistant_config(), cfg)
                print(
                    "Dumped home assistant configuration at",
                    self._options.config)
        self._connection.close()
        sys.exit(0)
341306
public function workerSignal(int $signal) {
        $this->log(LogLevel::DEBUG, "[{pid}] Caught signal '{$signal}' (SIGHUP) at worker - handing off to payload handler");

        switch ($signal) {

            // Daemon was asked to hang up
            case SIGHUP:
                $this->payloadExec('signal', [$signal]);
                break;

            // Custom signal - Nothing
            case SIGUSR1:
                $this->payloadExec('signal', [$signal]);
                break;

            // Custom signal - Nothing
            case SIGUSR2:
                $this->payloadExec('signal', [$signal]);
                break;
        }
    }
337865
public function addSignal($signal, $callback)
    {
        $event = event_new();
        $this->_signalEvents[$signal] = $event;
        event_set($event, $signal, EV_SIGNAL | EV_PERSIST, $callback);
        event_base_set($event, $this->_eventBase);
        event_add($event);
    }
571180
public function handleSignal($signal)
    {
        if (in_array($signal, $this->stopSignals)) {
            $this->logger->info(sprintf('Handle stop signal (%s)', $signal));
            $this->stop = true;
        } elseif (in_array($signal, $this->pauseSignals)) {
            $this->logger->info(sprintf('Handle pause signal (%s)', $signal));
            $this->pause = true;
        } elseif (in_array($signal, $this->resumeSignals)) {
            $this->logger->info(sprintf('Handle resume signal (%s)', $signal));
            $this->pause = false;
        }
    }
381970
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ObjectStateService\UpdateObjectStateGroupSignal) {
            return;
        }

        parent::receive($signal);
    }
760872
public function handleSignal($signal)
    {
        switch ($signal) {
        case SIGINT:
            $this->log(
                'Received SIGINT, shutting down.' . PHP_EOL,
                Net_Notifier_Logger::VERBOSITY_ALL
            );
            $this->moribund = true;
            break;

        case SIGTERM:
            $this->log(
                'Received SIGTERM, shutting down.' . PHP_EOL,
                Net_Notifier_Logger::VERBOSITY_ALL
            );
            $this->moribund = true;
            break;
        }
    }
338416
private function sendTERMSignal()
    {
        if (!$this->hasReceivedHUP) {
            $this->hasReceivedHUP = true;
            try {
                $this->process->signal(SIGTERM);
            } catch (\Symfony\Component\Process\Exception\LogicException $e) {
                //In case the process ends between checking and actually sending the signal
            }
        }
    }
1038471
protected function listenForSignals()
    {
        pcntl_async_signals(true);

        pcntl_signal(SIGTERM, function () {
            $this->pendingSignals['terminate'] = 'terminate';
        });

        pcntl_signal(SIGUSR1, function () {
            $this->pendingSignals['restart'] = 'restart';
        });

        pcntl_signal(SIGUSR2, function () {
            $this->pendingSignals['pause'] = 'pause';
        });

        pcntl_signal(SIGCONT, function () {
            $this->pendingSignals['continue'] = 'continue';
        });
    }
325514
public function onSignal($signo, callable $callback, $data = null) {
        $watcher = new Watcher;
        $watcher->type = Watcher::SIGNAL;
        $watcher->id = $this->nextId++;
        $watcher->callback = $callback;
        $watcher->value = $signo;
        $watcher->data = $data;

        $this->watchers[$watcher->id] = $watcher;
        $this->enableQueue[$watcher->id] = $watcher;

        return $watcher->id;
    }