Skip to content

kill: replace nix::sys::signal with rustix::process#12326

Merged
sylvestre merged 4 commits into
uutils:mainfrom
mattsu2020:kill_rustix
Jun 5, 2026
Merged

kill: replace nix::sys::signal with rustix::process#12326
sylvestre merged 4 commits into
uutils:mainfrom
mattsu2020:kill_rustix

Conversation

@mattsu2020
Copy link
Copy Markdown
Contributor

@mattsu2020 mattsu2020 commented May 16, 2026

Summary

  • Replace nix::sys::signal usage in the kill utility with rustix::process APIs as part of the migration away from nix (see chore(deps): update rust crate clap to v4.5.30 #7317)
  • Use rustix's explicit per-case APIs:
    • kill_process for positive PIDs
    • kill_process_group for negative PIDs
    • kill_current_process_group for PID 0
    • test_kill_* variants for signal 0
  • Keep a small raw libc::kill path for libc realtime signals (SIGRTMIN..=SIGRTMAX on Linux/Android), because rustix's Signal contract does not allow libc-reserved realtime signal values to be used for sending signals
  • Guard against i32::MIN overflow with checked_neg() when negating negative PIDs
  • Use safe Pid::from_raw() with expect() instead of Pid::from_raw_unchecked

Tests

  • cargo build -p uu_kill
  • cargo test -p coreutils --test tests --features kill -- test_kill_ (37 passed on macOS)

Note: the realtime signal send test is Linux/Android-only and is therefore not run on macOS.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 16, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.
Skip an intermittent issue tests/pr/bounded-memory (was skipped on 'main', now failing)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 16, 2026

Merging this PR will improve performance by 3.23%

⚡ 1 improved benchmark
✅ 322 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_summarize_balanced_tree[(5, 4, 10)] 6.9 ms 6.6 ms +3.23%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mattsu2020:kill_rustix (22dd686) with main (abcdcdc)

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.

Comment thread src/uu/kill/src/kill.rs
// file that was distributed with this source code.

// spell-checker:ignore (ToDO) signalname pids killpg
// spell-checker:ignore (ToDO) signalname pids killpg NSIG
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.

Suggested change
// spell-checker:ignore (ToDO) signalname pids killpg NSIG
// spell-checker:ignore (ToDO) signalname pids killpg

NSIG isn't used

Comment thread src/uu/kill/src/kill.rs
}

#[cfg(any(target_os = "linux", target_os = "android"))]
fn is_realtime_signal(sig: usize) -> bool {
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.

is it really necessary ?
from_named_raw returning None can replace the manual is_realtime_signal range check ?

@sylvestre sylvestre merged commit 533edad into uutils:main Jun 5, 2026
160 of 172 checks passed
@sylvestre
Copy link
Copy Markdown
Contributor

i will do a follow up pr instead

@sylvestre
Copy link
Copy Markdown
Contributor

#12636

@mattsu2020
Copy link
Copy Markdown
Contributor Author

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.

2 participants