Skip to content

Commit 82b31c4

Browse files
committed
fix: stop signal sending from child once interrupted, ensure child process is terminated
1 parent 738a73e commit 82b31c4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

PhpAmqpLib/Connection/Heartbeat/SIGHeartbeatSender.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function unregister(): void
5656
pcntl_signal($this->signal, SIG_IGN);
5757
if ($this->childPid > 0) {
5858
posix_kill($this->childPid, SIGKILL);
59+
pcntl_waitpid($this->childPid, $status);
5960
}
6061
$this->childPid = null;
6162
}
@@ -80,7 +81,11 @@ private function periodicAlarm(int $interval): void
8081
$pid = pcntl_fork();
8182
if(!$pid) {
8283
while (true){
83-
sleep($interval);
84+
$slept = sleep($interval);
85+
if ($slept !== 0) {
86+
// interupted by signal from parent, exit immediately
87+
exit;
88+
}
8489
posix_kill($parent, $this->signal);
8590
}
8691
} else {

0 commit comments

Comments
 (0)