Skip to content

fix(cli): handle closed stdout pipes - #1136

Merged
LunaStev merged 3 commits into
wavefnd:masterfrom
pranavsivrem-cloud:fix/1099-broken-pipe
Dec 5, 2026
Merged

LunaStev merged 3 commits into
wavefnd:masterfrom
pranavsivrem-cloud:fix/1099-broken-pipe

Conversation

@pranavsivrem-cloud

Copy link
Copy Markdown
Contributor

Summary

  • Handle a closed stdout pipe in wavec help, version, and print output and in wave-tools help and exec output.
  • Preserve ordinary output, existing command diagnostics and exit statuses when the pipe closes, and report other stdout write errors.
  • Add deterministic subprocess regressions that close the anonymous pipe's reader before starting the command.

Testing

  • Passed formatting and commit whitespace checks. Both regression files compiled to metadata, and all 26 utils tests passed.
  • A standalone Windows smoke test verified exact ordinary output, success with a closed pipe reader, and error propagation with read-only stdout.
  • Clippy passed for utils with the existing manual_is_multiple_of lint allowed. Strict Clippy flagged that lint in unchanged code.
  • The full wavec CLI regressions could not run locally because the LLVM 21.1 SDK and llvm-mc were unavailable.
  • The full wave-tools CLI regressions could not run locally because GNU import-library tooling was incomplete and the MSVC linker (link.exe) was unavailable.

This PR is a draft pending full CLI regression results.

Closes #1099

Preserve normal output, diagnostics, and exit statuses when a downstream reader closes stdout. Cover compiler help and print commands and tooling help and exec with anonymous-pipe regressions.

Refs wavefnd#1099

Signed-off-by: Tharunpranaav <pranavsivrem@gmail.com>
Refs wavefnd#1099

Signed-off-by: Tharunpranaav <pranavsivrem@gmail.com>

@LunaStev LunaStev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. The shared CliStdout abstraction and deterministic closed-reader regression tests are a good approach to resolving #1099.

Before merging, please address the following:

Required changes

  • Investigate and fix the non-BrokenPipe stdout error handling on Unix. The current CI results show that writing to read-only stdout can incorrectly return success without a diagnostic. Rust's standard stdout implementation may suppress EBADF.
  • Ensure that only BrokenPipe is silently ignored and that other stdout errors are reported correctly.
  • Fix the failing help_reports_other_stdout_errors and exec_preserves_child_status_and_stderr_when_stdout_closes regression tests without weakening their expected behavior.
  • Add regression coverage for wavec --version, which is also modified by this PR.
  • Verify the behavior on Linux, macOS, and Windows.

Additional considerations

  • Consider preserving child process status and diagnostics consistently between streaming and capture modes when stdout encounters a non-BrokenPipe error.
  • Consider explicit flush handling at CLI output boundaries and direct unit tests for CliStdout.

The overall implementation direction is appropriate. Please keep the deterministic OS-pipe regression approach.

Once these issues are addressed and the relevant CI checks pass, the PR can be reconsidered for approval.

Refs wavefnd#1099

Signed-off-by: Tharunpranaav <pranavsivrem@gmail.com>
@LunaStev
LunaStev marked this pull request as ready for review December 5, 2026 06:03

@LunaStev LunaStev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@LunaStev
LunaStev merged commit 126bb90 into wavefnd:master Dec 5, 2026
50 checks passed
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.

Handle a closed CLI stdout pipe without a printing panic

2 participants