Skip to content

Commit

Permalink
Add an explicit pcntl_wifexited check
Browse files Browse the repository at this point in the history
Looks like exit code is only valid if wifexited returns true: https://stackoverflow.com/questions/742413/return-code-when-os-kills-your-process
  • Loading branch information
daneren2005 committed Nov 15, 2021
1 parent 2f061bb commit a3a25ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Resque/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,18 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false)
));

// Wait until the child process finishes before continuing
while($lastWaitPIDStatus = pcntl_waitpid($this->child, $status, WNOHANG) == 0 && !$this->shutdown) {
while(pcntl_waitpid($this->child, $status, WNOHANG) == 0 && !$this->shutdown) {
usleep(250000);
}
$this->logger->log(Psr\Log\LogLevel::DEBUG, 'pcntl_waitpid return status of {status} for child {child} for {worker}', Array(
'status' => $lastWaitPIDStatus,
'status' => $status,
'child' => $this->child,
'worker' => $this
));

if(!$this->shutdown) {
$exitStatus = pcntl_wexitstatus($status);
if ($exitStatus !== 0) {
if ($exitStatus !== 0 || pcntl_wifexited($status) === FALSE) {
$this->logger->log(Psr\Log\LogLevel::NOTICE, 'Child {child} has failed for {worker}', Array(
'child' => $this->child,
'worker' => $this
Expand Down

0 comments on commit a3a25ee

Please sign in to comment.