Repository navigation
Wait for child processes through the fiber scheduler - #9803
Open
sampokuokkanen wants to merge 2 commits into
Open
sampokuokkanen wants to merge 2 commits into
sampokuokkanen wants to merge 2 commits into
Conversation
FiberScheduler.processWait was there, but nothing called it. Under a scheduler, Process.wait still blocked the whole thread. Blocking waits (no WNOHANG) now go to the scheduler's process_wait when it defines one, as rb_process_status_wait does in MRI. Callers of the long-returning waitpid still check errno, so Process::Status keeps the errno of a failed wait and we restore it from there. If the hook returns something other than a Process::Status, raise a TypeError. WNOHANG and WUNTRACED are now constants shared by the Ruby constants and the Java code.
Process.waitall called wait(2) directly, so it skipped the scheduler's process_wait. Loop over waitpid(-1) instead, as MRI's proc_waitall does. That waitpid already goes through the scheduler. Leave $? set to the last child's status, as MRI does.
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.
FiberScheduler.processWaitexisted, but nothing called it. So under a fiber scheduler,Process.wait,waitpid,wait2,Process::Status.waitandsystemblocked the whole thread instead of letting other fibers run.This sends blocking waits (no
WNOHANG) to the scheduler'sprocess_wait, the same way MRI'srb_process_status_waitdoes. A failed wait keeps its errno on theProcess::Status, so callers still raise the rightErrnoerror. If the hook returns something that isn't aProcess::Status, a TypeError is raised.The second commit does the same for
Process.waitall, which calledwait(2)directly. It now loops overwaitpid(-1), like MRI'sproc_waitall, and has a new ruby/spec.Tests:
Process.wait2andKernel#systemtests now seeprocess_waitcalled