Skip to content

Commit

Permalink
Merge pull request #15 from HongjiangHuang/master
Browse files Browse the repository at this point in the history
fix: recive ctrl+c signal kill  child process
  • Loading branch information
qxsch authored Mar 23, 2020
2 parents 2c0130d + ea023d4 commit 50b1d3b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/WorkerPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WorkerPool implements \Iterator, \Countable {

/** @var array signals, that should be watched */
protected $signals = array(
SIGCHLD, SIGTERM, SIGHUP, SIGUSR1
SIGCHLD, SIGTERM, SIGHUP, SIGUSR1, SIGINT
);

/** @var bool is the pool created? (children forked) */
Expand Down Expand Up @@ -339,6 +339,7 @@ protected function runWorkerProcess(WorkerInterface $worker, SimpleSocket $simpl
while (TRUE) {
$output = array('pid' => getmypid());
try {
pcntl_signal_dispatch();
$replacements['state'] = 'free';
ProcessDetails::setProcessTitle($this->childProcessTitleFormat, $replacements);
$cmd = $simpleSocket->receive();
Expand Down Expand Up @@ -781,4 +782,4 @@ public function rewind() {
public function valid() {
return !empty($this->results);
}
}
}

0 comments on commit 50b1d3b

Please sign in to comment.