We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 33f6264 commit c9c18ccCopy full SHA for c9c18cc
classes/util/PcntlTimeout.php
@@ -58,7 +58,9 @@ public function __construct(int $timeout)
58
*/
59
public function timeBoxed(callable $code)
60
{
61
- $signal = pcntl_signal(SIGALRM, function () {
+ $existingHandler = pcntl_signal_get_handler(SIGALRM);
62
+
63
+ $signal = pcntl_signal(SIGALRM, function (): void {
64
throw new DeadlineException(sprintf("Timebox hit deadline of %d seconds", $this->timeout));
65
});
66
if (!$signal) {
@@ -73,7 +75,7 @@ public function timeBoxed(callable $code)
73
75
} finally {
74
76
pcntl_alarm(0);
77
pcntl_signal_dispatch();
- pcntl_signal(SIGALRM, SIG_DFL);
78
+ pcntl_signal(SIGALRM, $existingHandler);
79
}
80
81
0 commit comments