Loop on EINTR - #22
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On MacOS, for the various wait functions to work properly you've had to wrap them in begin/rescue clauses for EINTR. This would automatically loop for you instead.
From Claude Opus 4.5:
When RUBY_UBF_PROCESS is used, Ruby sends a signal (typically SIGVTALRM or similar) to interrupt the blocking system call when it needs to regain control. This causes the
wait3()call to return -1 with errno set to EINTR.Why it works on Linux but fails on macOS:
On Linux, the
wait3()system call is often automatically restarted after being interrupted by a signal (depending on the signal and SA_RESTART flag settings). Ruby's internal signal handling on Linux tends to cooperate better with this pattern.However, MacOS does not automatically restart
wait3()after an EINTR. When the unblocking function sends a signal to interrupt the call, wait3() returns -1 with EINTR, and the code then callsrb_sys_fail("wait3")which raises the exception.