fix(acp): synchronously reap ACP child to avoid SIGCHLD race#9023
fix(acp): synchronously reap ACP child to avoid SIGCHLD race#9023
Conversation
Fixes #8373. The `console` crate has a bug in its use of select(): any interruption is treated as a fatal error and propagated. We were killing the ACP child and then immediately proceeding, which set up a race; if the child was reaped after select() started, the SIGCHLD interrupting select() caused the program to exit. Wait for the child to be reaped before proceeding to eliminate the race. Also, use Stdio::inherit() for child stderr to prevent ACP children which output anything on stderr from messing up the CLI.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa2cc085d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: jh-block <jhugo@block.xyz>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 302a3ab83a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Replace BufReader::split-based line splitting with manual chunked reads that flush at MAX_LINE_LEN (8 KiB) bytes. A child emitting \r-terminated progress output or binary data without newlines could otherwise grow a single Vec<u8> indefinitely while we wait for a newline that never arrives. Signed-off-by: jh-block <jhugo@block.xyz>
Fixes #8373.
Supersedes #8790.
The
consolecrate has a bug in its use of select(): any interruption is treated as a fatal error and propagated. We were killing the ACP child and then immediately proceeding, which set up a race; if the child was reaped after select() started, the SIGCHLD interrupting select() caused the program to exit.Wait for the child to be reaped before proceeding to eliminate the race.
Also, use
Stdio::inherit()for child stderr to prevent ACP children which output anything on stderr from messing up the CLI.Upstream PR fixing the bug in the
consolecrate: console-rs/console#286