install signal
@param  int      $signal e.g: SIGTERM SIGINT(Ctrl+C) SIGUSR1 SIGUSR2 SIGHUP
@param  callable $handler
@return bool
493287
public static function installSignal($signal, callable $handler): bool
    {
        if (!self::hasPcntl()) {
            return false;
        }

        return \pcntl_signal($signal, $handler, false);
    }
1204842
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ObjectStateService\SetContentStateSignal) {
            return;
        }

        $this->runLegacyKernelCallback(
            static function () use ($signal) {
                eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId);
                eZSearch::updateObjectState($signal->contentId, [$signal->objectStateId]);
                eZContentObject::clearCache(); // Clear all object memory cache to free memory
            }
        );
    }
799331
def enable_sig_handler(signal_name, handler):
    '''
    
    '''
    if hasattr(signal, signal_name):
        signal.signal(getattr(signal, signal_name), handler)
141800
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\TrashService\TrashSignal) {
            return;
        }

        if ($signal->contentTrashed) {
            $this->searchHandler->deleteContent(
                $signal->contentId
            );
        }

        $this->searchHandler->deleteLocation(
            $signal->locationId,
            $signal->contentId
        );
    }
1195771
public function install(array $signals)
    {
        if (self::isSupported()) {
            $callback = [$this, 'dispatchSignal'];
            foreach ($signals as $signal) {
                \pcntl_signal($signal, $callback);
            }
        };
    }
60669
protected function stopWorkers($signal = SIGTERM)
    {
        if (!$this->workers) {
            $this->log('No child process(worker) need to stop', ProcessLogger::PROC_INFO);

            return false;
        }

        return ProcessUtil::stopChildren($this->workers, $signal, [
            'beforeStops' => function ($sigText) {
                $this->log("Stopping workers({$sigText}) ...", ProcessLogger::PROC_INFO);
            },
            'beforeStop' => function ($pid, $info) {
                $this->log("Stopping worker #{$info['id']}(PID:$pid)", ProcessLogger::PROC_INFO);
            },
        ]);
    }
540451
public function subscribe($signal, $callback)
  {
    if(empty($this->sigslots[$signal]))
    {
      $this->sigslots[$signal] = array();
    }

    $index = $this->getCallbackHash($callback);

    if(!array_key_exists($index, $this->sigslots[$signal]))
    {
      $this->sigslots[$signal][$index] = new TeamSpeak3_Helper_Signal_Handler($signal, $callback);
    }

    return $this->sigslots[$signal][$index];
  }
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)
        );
    }
1337654
def add_signal_handlers(self):
        """"""
        try:
            self.loop.add_signal_handler(signal.SIGHUP, self.SIGHUP)
        except (RuntimeError, AttributeError):  # pragma: no cover
            # windows
            pass
        try:
            self.loop.add_signal_handler(signal.SIGINT, self.SIGINT)
        except (RuntimeError, NotImplementedError):  # pragma: no cover
            # annaconda
            pass
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.");
		}
	}
1191392
public function signalReceived($signal)
    {
        if ($signal === 'submit') {
            if (!$this->getPresenter()->getRequest()->hasFlag(Nette\Application\Request::RESTORED)) {
                $this->fireEvents();
            }
        } else {
            $class = get_class($this);
            throw new BadSignalException("Missing handler for signal '$signal' in $class.");
        }
    }
539415
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ObjectStateService\CreateObjectStateSignal) {
            return;
        }

        parent::receive($signal);
    }
1354196
public static function signal($signals, $callback)
    {
        foreach ($signals as $signal) {
            if (is_null($callback)) {
                \Swoole\Process::signal($signal, null);
                continue;
            }
            \Swoole\Process::signal($signal, function ($signal) use ($callback) {
                try {
                    call_user_func($callback, $signal);
                } catch (\Throwable $e) {
                    \Mix::$app->error->handleException($e);
                }
            });
        }
    }
421489
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ContentService\CopyContentSignal) {
            return;
        }

        $this->searchHandler->indexContent(
            $this->persistenceHandler->contentHandler()->load(
                $signal->dstContentId,
                $signal->dstVersionNo
            )
        );

        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
            $signal->dstContentId
        );
        foreach ($locations as $location) {
            $this->searchHandler->indexLocation($location);
        }
    }
1106210
public function broadcast($signal) {
        if ($signal == SIGINT || $signal == SIGKILL) {
            $this->isStopped = true;
        }
        foreach ($this->handlers as $handler) {
            posix_kill($handler, $signal);
        }
    }
796150
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ContentService\DeleteContentSignal) {
            return;
        }

        $this->runLegacyKernelCallback(
            static function () use ($signal) {
                eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId);
                eZSearch::removeObjectById($signal->contentId, null);
                eZContentObject::clearCache(); // Clear all object memory cache to free memory
            }
        );
    }
464380
public function signalReceived($signal): void
    {
        $form = $this->getForm();
        /** @var Presenter $presenter */
        $presenter = $this->getPresenter();
        $request = $presenter->getRequest();

        switch ($signal) {
            case 'submit':
                $this->processSubmit($form, $request);
                break;
            case 'validate':
                $this->processValidate($form, $request);
                break;
            case 'render':
                $this->processRender($form, $request);
                break;
            default:
                throw new BadSignalException(
                    sprintf('Missing handler for signal "%s" in %s.', $signal, get_class($this))
                );
        }
    }