Repository navigation
Document Errno::ECHILD when something else reaps the command - #36
Merged
Merged
Conversation
Errno::ECHILD when something else reaps the command
If something else in the process reaps the command first, as a CHLD trap handler that waits on children does, or the kernel when CHLD is ignored, the wait after the read raises Errno::ECHILD and the output is lost. The documentation said a SystemCallError means the program could not start, so a caller would read it as the command not having run, and said every method sets $?. The status cannot be recovered once another waiter has it, so execute? and execute! cannot answer their question. Keep the raise, and document it in its own @raise tag and in the README: the command ran, the output it would have returned and its status are lost, a stream redirected to a file is still written, and $? is not set. Qualify the two places that say every method sets $?. The example ignores CHLD, which makes the kernel reap children at once. TruffleRuby does not pass that on to its children, so the example runs on CRuby only.
orien
force-pushed
the
document-echild
branch
from
November 29, 2026 14:54
501a2d7 to
fd85063
Compare
orien
marked this pull request as ready for review
November 29, 2026 14:54
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.
Context
If something else in the process reaps the command before SafeShell does, such as a
trap("CHLD")handler that waits on children, or the kernel whenCHLDis ignored, the wait after the read raisesErrno::ECHILDand the command's output is discarded. The docs say aSystemCallErrormeans the program could not be started, and that every method sets$?, so a caller reads this as the command not having run and trusts a$?that describes another command.PE-8869
Change
Documents the raise in its own
@raisetag onexecuteand in the README:$?is not set: it is nil, unchanged from the previous command, or whatever the other waiter reaped. The module doc and the README's$?sentence are qualified to match.CHLDand checks, for each of the three methods, that it raises after the command has run and leaves$?unchanged.Considerations
execute?andexecute!cannot answer their question.CHLDdoes not make the kernel reap its children, so nothing raises.