Skip to content

Dispatch async signals during time_sleep_until() - #24400

Open
nicolas-grekas wants to merge 1 commit into
php:masterfrom
nicolas-grekas:time-sleep-until-async-signals
Open

nicolas-grekas wants to merge 1 commit into
php:masterfrom
nicolas-grekas:time-sleep-until-async-signals

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Related to bug #38480 and to #22538.

With pcntl_async_signals(true), signal handlers now run while time_sleep_until() waits. A handler can throw or exit before the deadline. If the handler returns, the sleep resumes until the original deadline.

#24399 already made the sleep resume with the remaining time. This PR adds the missing part. When nanosleep() is interrupted, time_sleep_until() now calls zend_fcall_interrupt(), like the VM does after an internal function returns. As a consequence, max_execution_time can also stop the sleep when its timer interrupts nanosleep().

A signal that arrives while another handler is running still waits for the deadline, because pcntl blocks signals during a handler.

@nicolas-grekas
nicolas-grekas force-pushed the time-sleep-until-async-signals branch from 5455d2c to 3a54a79 Compare November 12, 2026 17:24
@nicolas-grekas

Copy link
Copy Markdown
Contributor Author

Rebased. #24399 already merged the part that resumes the sleep, so this PR is now 6 lines plus tests. I added a test for the sleep resuming after a handler returns, and I updated the description.

@arnaud-lb WDYT of this as a first step before #22538 reaches the other EINTR loops? There's one difference with #22538. Here the sleep always resumes when the handler returns, whatever $restart_syscalls says.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant