Skip to content

who: report a stdout write error instead of panicking#13389

Open
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:who-fix-write-error
Open

who: report a stdout write error instead of panicking#13389
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:who-fix-write-error

Conversation

@leeewee

@leeewee leeewee commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #13388

who -q (--count) printed the user list and the trailing count with println!, which aborts (exit 134) when stdout can't be written — e.g. output redirected to a full device. GNU reports the write error and exits 1.

Both stdout output paths now go through a helper that propagates the failure: on error it reports a GNU-style write error: <reason> to stderr and exits 1.

Before:

$ who -q > /dev/full
thread 'main' panicked at library/std/src/io/stdio.rs:...:
failed printing to stdout: No space left on device
Aborted (core dumped)          # exit 134

After:

$ who -q > /dev/full
who: write error: No space left on device        # exit 1

The non--q record-listing path already propagated its write error but reported it without the write error: prefix (who: No space left on device); it now routes through the same helper, so both paths match GNU (who: write error: No space left on device, exit 1).

Same write-error class as chcon (#13061), kill (#13297), and runcon. The existing --heading /dev/full test is updated to the new message, and a -q regression test is added.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/io-errors (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)

Comment thread src/uu/who/src/platform/unix.rs Outdated
translate!("who-long-usage", "default_file" => utmpx::DEFAULT_FILE)
}

fn write_error(e: std::io::Error) -> Box<dyn UError> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use thiserror, see #13397.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved, thanks!

`who -q` printed the user list and count with `println!`, which aborts
(exit 134) when stdout can't be written, e.g. `who -q > /dev/full`. Write
through a helper that propagates the failure: on error it reports a
GNU-style `write error: <reason>` to stderr and exits 1.

The non-`-q` record path already propagated its write error but reported
it without the `write error:` prefix; route it through the same helper so
both paths match GNU.

Fixes uutils#13388
@leeewee
leeewee force-pushed the who-fix-write-error branch from b758bcd to de85c9d Compare July 15, 2026 04:50
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.

who -q panics (aborts) on a stdout write error when output to /dev/full

2 participants