Skip to content

cli: handle broken stdout pipes gracefully - #14

Open
dishendradeshmukh1986 wants to merge 1 commit into
linuxboot:mainfrom
dishendradeshmukh1986:fix/broken-stdout-pipe
Open

cli: handle broken stdout pipes gracefully#14
dishendradeshmukh1986 wants to merge 1 commit into
linuxboot:mainfrom
dishendradeshmukh1986:fix/broken-stdout-pipe

Conversation

@dishendradeshmukh1986

Copy link
Copy Markdown

Summary

  • replace infallible stdout print macros with fallible writes
  • treat BrokenPipe as normal command termination
  • cover the broken-pipe path with a regression test

Problem

Commands that produce large output panic when the pipe consumer exits
early. For example:

uefisettings show-translations | head -n 10

head closes the pipe after ten lines, and Rust's println! macro
panics when the following stdout write returns EPIPE.

Fix

Propagate stdout write errors through the command handlers and return
success when the error chain contains BrokenPipe. Other I/O errors
continue to use the existing command error path.

Validation

  • cargo test --bin uefisettings
  • cargo test --lib
  • cargo run --quiet -- show-translations | head -n 10

Rust's print macros panic when stdout returns EPIPE after a pipe
consumer exits early.

Write command output through fallible helpers and treat BrokenPipe as
normal termination. This allows commands such as show-translations to
be safely piped to head.

Signed-off-by: Dishendra Deshmukh <dishendra.deshmukh@arm.com>
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.

1 participant