Send kill signal to supervisord

@param string $signal
@param bool $waitForProcessToDisappear
514208
public function kill($signal = '', $waitForProcessToDisappear = false)
    {
        $pid = $this->getSupervisorPid();
        if (!empty($pid) && $this->isProcessRunning($pid)) {
            if (!empty($signal)) {
                $signal = sprintf('-%s', $signal);
            }

            $command = sprintf('kill %s %d', $signal, $pid);

            passthru($command);

            if ($waitForProcessToDisappear) {
                $this->wait();
            }
        }
    }
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
        );
    }
142606
public function terminate($signal = null)
    {
        if ($this->process === null) {
            return false;
        }

        if ($signal !== null) {
            return \proc_terminate($this->process, $signal);
        }

        return \proc_terminate($this->process);
    }
74815
def process_kill(pid, sig=None):
    
    sig = sig or signal.SIGTERM
    os.kill(pid, sig)
754915
public function terminateProcess($pid, $sig = SIGTERM) {
		if (!$pid) {
			return;
		}

		$killed = false;
		if (function_exists('posix_kill')) {
			$killed = posix_kill($pid, $sig);
		}
		if (!$killed) {
			exec('kill -' . $sig . ' ' . $pid);
		}
		sleep(1);

		$QueueProcesses = TableRegistry::get('Queue.QueueProcesses');
		$QueueProcesses->deleteAll(['pid' => $pid]);
	}
162089
public function stop( $_signal = SIGKILL, $_wait = false ) {
		if( $this->isAlive() ) {
			posix_kill( $this->pid, $_signal );
			if( $_wait ) {
				pcntl_waitpid( $this->pid, $status = 0 );
			}
		}
	}
1189189
public function pause()
    {
        $this->paused = true;

        if($this->getProcess()->getPid() == getmypid()) {
            $this->getLogger()->notice('SIGUSR2 received; pausing job processing');
        }else{
            $this->getProcess()->kill(SIGUSR2);
        }

    }
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;
        }
    }
745291
public function kill(int $pid, bool $wait = false): bool
    {
        return $this->process->kill($pid, $wait);
    }
1182478
def _kill_process0(self, pid, sig=signal.SIGKILL):
        
        if self._user is None:
            super(RunExecutor, self)._kill_process(pid, sig)
        else:
            logging.debug('Sending signal %s to %s with sudo.', sig, pid)
            try:
                # Cast sig to int, under Python 3.5 the signal.SIG* constants are nums, not ints.
                subprocess.check_call(args=self._build_cmdline(['kill', '-'+str(int(sig)), str(pid)]))
            except subprocess.CalledProcessError as e:
                # may happen for example if process no longer exists
                logging.debug(e)
1315009
public function sendSignal(int $signal) {
        $runningPid = $this->lock->getRunningPID();
        if (!$runningPid) {
            return false;
        }

        // Send signal
        return posix_kill($runningPid, $signal);
    }
903980
def wait_for_child_and_forward_all_signals(child_pid, process_name):
    
    assert _HAS_SIGWAIT
    block_all_signals()

    while True:
        logging.debug("Waiting for signals")
        signum = signal.sigwait(_ALL_SIGNALS)
        if signum == signal.SIGCHLD:
            pid, exitcode, ru_child = os.wait4(-1, os.WNOHANG)
            while pid != 0:
                if pid == child_pid:
                    return exitcode, ru_child
                else:
                    logging.debug("Received unexpected SIGCHLD for PID %s", pid)
                pid, exitcode, ru_child = os.wait4(-1, os.WNOHANG)

        else:
            _forward_signal(signum, child_pid, process_name)
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)
1312526
def signal_all(signal="KILL")
      signaled = 0
      if (!@forks.nil? && (@forks.count > 0))
        @forks.each do |fork|
          begin
            Process.kill(signal, fork[:pid])
            signaled += 1
          rescue
            nil
          end
        end
      end
      signaled
    end
551141
protected function killProcess($pid, $sig, $wait = 0)
    {
        Process::kill($pid, $sig);

        if ($wait) {
            $start = time();

            do {
                if (! $this->isRunning($pid)) {
                    break;
                }

                usleep(100000);
            } while (time() < $start + $wait);
        }

        return $this->isRunning($pid);
    }
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);
            },
        ]);
    }
60834
function signalHandler(signal)
{
    var exit = true;
    cleanupHandlers.forEach(function (cleanup) {
        if (cleanup(null, signal) === false)
            exit = false;
    });
    if (exit) {
        if (signal === 'SIGINT' && messages && messages.ctrl_C !== '')
            process.stderr.write(messages.ctrl_C + "\n");
        uninstall(); // don't cleanup again
        // necessary to communicate the signal to the parent process
        process.kill(process.pid, signal);
    }
}