Repository navigation
fix(console): surface stdout write failures with GNU exit mapping (#1368) - #1419
Merged
Merged
Conversation
) The shared console layer now records the first failed stdout write (broken pipe vs other errors) and exposes a report_stdout_write_error() query. seq, cat, printf, grep, ls, find, tac and tty consult it on their exit paths: a closed stdout (>&-) now reports "<prog>: write error: Bad file descriptor" with the tool's GNU exit status, and a broken pipe stops the producer early (seq N | head -1 no longer formats the whole stream). Per-command exit mapping follows GNU: cat/printf/seq/tac report the write error, grep/ls exit 2, find exits 1.
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.
Fixes #1368.
The shared console layer (
src/utils/console.cppm) now records the first failed stdout write and exposesreport_stdout_write_error(prog, fatal_status); the issue's named commands consult it on their exit paths:seq 3 >&-seq: write error: Bad file descriptor, rc1printf 'hi\n' >&-grep x f >&-ls >&-find . -print >&-tac f >&-cat f >&-cat: write error, rc1Broken-pipe failures keep their quiet SIGPIPE-style death, and the write-error state stops the producer early —
seq 5000000 | head -1no longer formats the whole stream. stderr writes (safeErrorPrint) are unaffected; console (WriteConsoleW) paths are untouched.Tests: per-command regression pins landed in the seq/cat/grep/ls/printf/tac/find/tty unit tests (closed-stdout and broken-pipe fixtures). Full suite: 3349 passed, 0 failed (baseline xargs CONIN$ / issue_1288 / find.issue_1309 exclusions).
i18n delta: new diagnostic strings ("write error: Bad file descriptor" family) are composed at runtime from the program name + strerror text; no catalog keys added or removed (extract byte-identical).