Skip to content

Drain command output before waiting for the child - #49

Closed
OskarEichler wants to merge 2 commits into
ruby-gnome:mainfrom
OskarEichler:codex/drain-command-output
Closed

OskarEichler wants to merge 2 commits into
ruby-gnome:mainfrom
OskarEichler:codex/drain-command-output

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Read the pipe before waiting for the child, so a full stdout pipe cannot deadlock native pkg-config discovery.

Reproduction and verification

PackageConfig.send(:run_command, RbConfig.ruby, "-e", 'STDOUT.write("x" * 1048576)') does not finish on baseline: the parent waits for exit while the writer waits for pipe space. The isolated reproduction used a three-second deadline and killed/waited for the entire process group. Empty/small output succeeds on both versions. The candidate returns all 1 MiB; a writer that emits 1 MiB then exits 7 returns nil as before.

Four isolated process cases pass; both large-output baseline cases exceeded the deadline.

Existing suite on Ruby 4.0.6 through rbenv: 27 tests, 31 assertions, zero failures/errors, two upstream macOS omissions, baseline and this isolated patch. Combined installed-release consumer also passes the suite, 1,098 focused/model checks, four process cases, five linker-option cases and four path cases. rbenv exec ruby test/run.rb runs the existing suite.

Compatibility and limitations

No API or successful-output change. Nonzero exits still return nil. This fixes the full-pipe deadlock, not arbitrary hanging commands; no command timeout or streaming API is added.

No tests were added or modified under the consuming repository's no-new-tests policy. Verification uses existing tests and external scratch reproductions. No production changes; older Ruby/Linux/Windows matrices await upstream CI. No unrelated version/dependency changes.

@kou

kou commented Aug 28, 2026

Copy link
Copy Markdown
Member

Do you have any real-world problem by this?

@OskarEichler

Copy link
Copy Markdown
Author

No; this came from the broad dependency audit rather than a real-world failure. I do not have enough project-specific motivation to ask you to carry the change, so I am closing it.

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.

2 participants