CmdRun: join pipe reader threads before close returns - #1134
Open
satishnaidu77 wants to merge 1 commit into
Open
satishnaidu77 wants to merge 1 commit into
satishnaidu77 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change directly addresses the described race by joining the stdout/stderr reader threads before returning from close, and includes a targeted regression spec to prevent reintroduction.
Pull request overview
This PR fixes a race in AutoHCK::CmdRun#close where the method could return after the child process exited but before the stdout/stderr pipe-reader threads finished buffering output, leading callers to observe incomplete stddata.
Changes:
- Track stdout/stderr pipe reader threads in
@pipe_threads. - Join pipe reader threads in
#closeafterProcess.wait2and before returning. - Add an RSpec example that verifies stdout is complete immediately after
closereturns (no polling).
File summaries
| File | Description |
|---|---|
| lib/auxiliary/cmd_run.rb | Tracks pipe reader threads and joins them during close so stddata is fully buffered before returning. |
| spec/lib/auxiliary/cmd_run_spec.rb | Adds a regression test for the stdout-buffering race by producing slow, line-by-line output and asserting completeness after close. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
ok to test |
Contributor
|
rerun tests |
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.
Summary
CmdRun#closewaited for the child process withProcess.wait2, then returned immediately while stdout/stderr were still being read in background threads. Callers that inspectstddataright afterclosecould see incomplete output.This showed up in functest host commands (e.g.
ping -c 10): the command succeeded and printedPASS:, but validation ran before the last lines were buffered, causing false failures likeexpected to contain 'PASS:'.Fix
@pipe_threadscloseafterwait2and before returningTest
Add a spec that runs slow stdout and asserts
stddata['stdout']is complete whenclosereturns (no polling). Existingcmd_run_spectests check exit status and logging, but do not cover this race.Test plan
bundle exec rspec spec/lib/auxiliary/cmd_run_spec.rb— 8 examples, 0 failures