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

This commit is contained in:
mattsu
2026-06-05 13:09:15 +02:00
committed by GitHub
parent abcdcdca53
commit 533edad992
4 changed files with 143 additions and 25 deletions
+46
View File
@@ -493,3 +493,49 @@ fn test_kill_signal_only_no_pid() {
.fails()
.stderr_contains("no process ID specified");
}
#[test]
fn test_kill_signal_zero_process() {
let target = Target::new();
// kill -0 should succeed for a running process (signal 0 = existence check)
new_ucmd!()
.arg("-0")
.arg(format!("{}", target.pid()))
.succeeds();
}
#[test]
fn test_kill_signal_zero_new_form() {
let target = Target::new();
// kill -s 0 should also work
new_ucmd!()
.arg("-s")
.arg("0")
.arg(format!("{}", target.pid()))
.succeeds();
}
#[test]
fn test_kill_signal_zero_nonexistent() {
// kill -0 with a nonexistent PID should fail
new_ucmd!().arg("-0").arg("999999999").fails();
}
#[test]
fn test_kill_signal_zero_current_process_group() {
// kill -0 0 should succeed (checks current process group)
new_ucmd!().arg("-0").arg("0").succeeds();
}
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_kill_realtime_signal() {
let mut target = Target::new();
// kill -s RTMIN should send SIGRTMIN and terminate the process
new_ucmd!()
.arg("-s")
.arg("RTMIN")
.arg(format!("{}", target.pid()))
.succeeds();
assert_eq!(target.wait_for_signal(), Some(libc::SIGRTMIN()));
}