Symfony\Component\Process\Process::doSignal PHP Method

doSignal() private method

Sends a POSIX signal to the process.
private doSignal ( integer $signal, boolean $throwException ) : boolean
$signal integer A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
$throwException boolean Whether to throw exception in case signal failed
return boolean True if the signal was sent successfully, false otherwise
    private function doSignal($signal, $throwException)
    {
        if (null === ($pid = $this->getPid())) {
            if ($throwException) {
                throw new LogicException('Can not send signal on a non running process.');
            }
            return false;
        }
        if ('\\' === DIRECTORY_SEPARATOR) {
            exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
            if ($exitCode && $this->isRunning()) {
                if ($throwException) {
                    throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
                }
                return false;
            }
        } else {
            if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
                $ok = @proc_terminate($this->process, $signal);
            } elseif (function_exists('posix_kill')) {
                $ok = @posix_kill($pid, $signal);
            } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
                $ok = false === fgets($pipes[2]);
            }
            if (!$ok) {
                if ($throwException) {
                    throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
                }
                return false;
            }
        }
        $this->latestSignal = (int) $signal;
        $this->fallbackStatus['signaled'] = true;
        $this->fallbackStatus['exitcode'] = -1;
        $this->fallbackStatus['termsig'] = $this->latestSignal;
        return true;
    }