mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
kill: return 1 and gnu style stderr in case of no pid (#6225)
* kill: return 1 and gnu style stderr in case of no pid closes #6221 * Update src/uu/kill/src/kill.rs Co-authored-by: Ben Wiederhake <BenWiederhake.GitHub@gmx.de> --------- Co-authored-by: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
This commit is contained in:
parent
aaaf4c3f91
commit
9b4a787be7
2 changed files with 18 additions and 2 deletions
|
@ -64,9 +64,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.try_into()
|
.try_into()
|
||||||
.map_err(|e| std::io::Error::from_raw_os_error(e as i32))?;
|
.map_err(|e| std::io::Error::from_raw_os_error(e as i32))?;
|
||||||
let pids = parse_pids(&pids_or_signals)?;
|
let pids = parse_pids(&pids_or_signals)?;
|
||||||
|
if pids.is_empty() {
|
||||||
|
Err(USimpleError::new(
|
||||||
|
1,
|
||||||
|
"no process ID specified\n\
|
||||||
|
Try --help for more information.",
|
||||||
|
))
|
||||||
|
} else {
|
||||||
kill(sig, &pids);
|
kill(sig, &pids);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Mode::Table => {
|
Mode::Table => {
|
||||||
table();
|
table();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -204,3 +204,11 @@ fn test_kill_with_signal_prefixed_name_new_form() {
|
||||||
.succeeds();
|
.succeeds();
|
||||||
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_kill_no_pid_provided() {
|
||||||
|
// spell-checker:disable-line
|
||||||
|
new_ucmd!()
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("no process ID specified");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue