Skip to content

Commit 6fd7fe5

Browse files
committed
Call posix_kill() in defer for better consistency
Using a short delay was sometimes not long enough to ensure that $sig2 was actually enabled before the signal was sent. Using a defer after enabling pushes the call to posix_kill() to the next tick.
1 parent 8c20631 commit 6fd7fe5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Test.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,11 @@ function testSignalExecutionOrder()
577577
$loop->onSignal(SIGUSR1, $f(5));
578578
$loop->defer(function() use ($loop, $sig2) {
579579
$loop->enable($sig2);
580-
});
581-
582-
$loop->delay($msDelay = 1, function() use ($loop) {
583-
\posix_kill(\getmypid(), \SIGUSR1);
584-
$loop->delay($msDelay = 10, function() use ($loop) {
585-
$loop->stop();
580+
$loop->defer(function() use ($loop) {
581+
\posix_kill(\getmypid(), \SIGUSR1);
582+
$loop->delay($msDelay = 10, function() use ($loop) {
583+
$loop->stop();
584+
});
586585
});
587586
});
588587
});

0 commit comments

Comments
 (0)