Skip to content

kill: report write errors when listing signals instead of panicking#13300

Merged
cakebaker merged 1 commit into
uutils:mainfrom
leeewee:kill-fix-list-write-error
Jul 8, 2026
Merged

kill: report write errors when listing signals instead of panicking#13300
cakebaker merged 1 commit into
uutils:mainfrom
leeewee:kill-fix-list-write-error

Conversation

@leeewee

@leeewee leeewee commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #13297

kill -l, kill -l <sig>, kill --list, and kill --table print their output
with println!, whose internal io::stdout().write_fmt().unwrap() aborts the
process (SIGABRT, exit 134) when the stdout write fails.

Adds a kill-error-write-error locale key (en-US, fr-FR) and a regression test
that lists signals to /dev/full.

Comment thread src/uu/kill/src/kill.rs Outdated
if let Some(signal_name) = signal_list_name_by_value(signal_value) {
println!("{signal_value: >#2} {signal_name}");
writeln!(out, "{signal_value: >#2} {signal_name}")
.map_err_context(|| translate!("kill-error-write-error"))?;

@oech3 oech3 Jul 7, 2026

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 extract error from OS instead of using translate!, or error message would be incorrect.

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.

Done — added a stdout_write_error helper that interpolates the OS error via uucore::error::strip_errno(&err) into the message (ftl key is now write error: { $err }), matching the head idiom. Output is unchanged: kill: write error: No space left on device.

Comment thread src/uu/kill/src/kill.rs Outdated
}
}
out.flush()
.map_err_context(|| translate!("kill-error-write-error"))

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.

Should be done after writeln!, not here.

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.

The OS-error extraction is now applied consistently with .map_err(stdout_write_error) on each writeln! as well as the final flush. I kept the BufWriter because head's line path does the same (BufWriter::with_capacity(BUF_SIZE, stdout.lock())) — buffering makes the failed write surface as one clean error at flush; writing unbuffered per line reintroduces the runtime's Error flushing stdout message on top of ours.

`kill -l`, `kill -l <sig>`, `kill --list`, and `kill --table` printed their
output with `println!`, whose internal `io::stdout().write_fmt().unwrap()`
aborts the process (SIGABRT, exit 134) when the stdout write fails — e.g.
`kill -l TERM > /dev/full`.

Write the signal listing to a buffered stdout and propagate the `io::Error`
via `?`, so a failed write reports `kill: write error: <reason>` and exits 1,
matching procps-ng `kill` (GNU coreutils ships no standalone `kill`). Add a
`kill-error-write-error` locale key (en-US, fr-FR) and a regression test that
lists signals to `/dev/full`.
@leeewee
leeewee force-pushed the kill-fix-list-write-error branch from 10a6213 to b873bc4 Compare July 8, 2026 06:33
@cakebaker
cakebaker merged commit 5d71e9a into uutils:main Jul 8, 2026
178 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

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.

kill -l / --list / --table redirected to /dev/full panics (aborts) on the write error

3 participants