From d8308512b73cb2f26a337a1ed5f3f1a71e18983f Mon Sep 17 00:00:00 2001 From: Dan Hunsaker Date: Tue, 11 Dec 2018 01:00:35 -0700 Subject: [PATCH] Apply old PR 189 Closes chrisboulton/php-resque#189 --- lib/Resque/Worker.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index 2408445..7935cec 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -257,7 +257,14 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false) $this->logger->log(Psr\Log\LogLevel::INFO, $status); // Wait until the child process finishes before continuing - pcntl_wait($status); + while (pcntl_wait($status, WNOHANG) === 0) { + if(function_exists('pcntl_signal_dispatch')) { + pcntl_signal_dispatch(); + } + + // Pause for a half a second to conserve system resources + usleep(500000); + } if (pcntl_wifexited($status) !== true) { $job->fail(new Resque_Job_DirtyExitException('Job exited abnormally'));