Skip to content

Commit 7b0d6c8

Browse files
oech3cakebaker
authored andcommitted
kill: remove useless fn rustix_to_io
1 parent e1fa1f8 commit 7b0d6c8

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/uu/kill/src/kill.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,6 @@ fn list(signals: &Vec<String>) {
224224
}
225225
}
226226

227-
fn rustix_to_io(result: rustix::io::Result<()>) -> io::Result<()> {
228-
result.map_err(io::Error::from)
229-
}
230-
231227
// rustix's `Signal` rejects libc-reserved realtime signals, so fall back to a
232228
// raw `libc::kill` for any value its safe constructor doesn't recognize.
233229
fn raw_kill(pid: i32, sig: usize) -> io::Result<()> {
@@ -273,15 +269,15 @@ fn kill(sig: usize, pids: &[i32]) {
273269
for &pid in pids {
274270
let result = match pid.cmp(&0) {
275271
Ordering::Equal => match named {
276-
_ if sig == 0 => rustix_to_io(test_kill_current_process_group()),
277-
Some(s) => rustix_to_io(kill_current_process_group(s)),
272+
_ if sig == 0 => test_kill_current_process_group().map_err(io::Error::from),
273+
Some(s) => kill_current_process_group(s).map_err(io::Error::from),
278274
None => raw_kill(0, sig),
279275
},
280276
Ordering::Greater => {
281277
let pid = Pid::from_raw(pid).expect("pid > 0 guaranteed by Ordering::Greater");
282278
match named {
283-
_ if sig == 0 => rustix_to_io(test_kill_process(pid)),
284-
Some(s) => rustix_to_io(kill_process(pid, s)),
279+
_ if sig == 0 => test_kill_process(pid).map_err(io::Error::from),
280+
Some(s) => kill_process(pid, s).map_err(io::Error::from),
285281
None => raw_kill(pid.as_raw_nonzero().get(), sig),
286282
}
287283
}
@@ -296,8 +292,8 @@ fn kill(sig: usize, pids: &[i32]) {
296292
let pid =
297293
Pid::from_raw(abs_pid).expect("abs_pid > 0 since pid < 0 and pid != i32::MIN");
298294
match named {
299-
_ if sig == 0 => rustix_to_io(test_kill_process_group(pid)),
300-
Some(s) => rustix_to_io(kill_process_group(pid, s)),
295+
_ if sig == 0 => test_kill_process_group(pid).map_err(io::Error::from),
296+
Some(s) => kill_process_group(pid, s).map_err(io::Error::from),
301297
None => raw_kill(-pid.as_raw_nonzero().get(), sig),
302298
}
303299
}

0 commit comments

Comments
 (0)