Skip to content

Loop on EINTR - #22

Merged
djberg96 merged 1 commit into
mainfrom
loop_on_eintr
Jan 10, 2026
Merged

Loop on EINTR#22
djberg96 merged 1 commit into
mainfrom
loop_on_eintr

Conversation

@djberg96

Copy link
Copy Markdown
Owner

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 calls rb_sys_fail("wait3") which raises the exception.

@djberg96
djberg96 merged commit b3aa9d7 into main Jan 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant