Skip to content

who: fix panic in -q/--count on stdout write error#13452

Open
koopatroopa787 wants to merge 2 commits into
uutils:mainfrom
koopatroopa787:fix-who-count-write-error
Open

who: fix panic in -q/--count on stdout write error#13452
koopatroopa787 wants to merge 2 commits into
uutils:mainfrom
koopatroopa787:fix-who-count-write-error

Conversation

@koopatroopa787

Copy link
Copy Markdown
Contributor

Summary

who -q (--count) prints a user list and a count line using println!, which aborts (panics) if stdout write fails — e.g. when output is redirected to /dev/full:

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

Fix: replace the two println! calls in the short_list branch of Who::exec() with writeln! on a locked stdout handle, so errors are propagated via ? and reported gracefully.

Fixes #13388

Changes

  • src/uu/who/src/platform/unix.rs: replace println! with writeln!(out, …)? for user list and count output
  • tests/by-util/test_who.rs: add test_count_write_error (Linux only, via /dev/full) to confirm the error is reported rather than causing an abort

`who -q` printed the user list and count with `println!`, which aborts
on a write error (e.g. when output is redirected to /dev/full).  Replace
both calls with `writeln!` against a locked stdout handle so errors are
propagated to the caller and reported gracefully.

Fixes uutils#13388
Copilot AI review requested due to automatic review settings July 19, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 339 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing koopatroopa787:fix-who-count-write-error (ea4ab22) with main (ef50d8b)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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

3 participants