Skip to content

Commit 2f943c4

Browse files
committed
pkill: fix CI failures for windows
1 parent db696af commit 2f943c4

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/uu/pkill/src/pkill.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
// Pid utils
77
use clap::{arg, crate_version, Arg, ArgAction, ArgGroup, ArgMatches, Command};
8-
#[cfg(target_os = "linux")]
9-
use nix::sys::signal::{self, Signal};
10-
#[cfg(target_os = "macos")]
8+
#[cfg(unix)]
119
use nix::sys::signal::{self, Signal};
10+
#[cfg(unix)]
1211
use nix::unistd::Pid;
1312
use regex::Regex;
1413
use std::io::Error;
@@ -126,6 +125,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
126125
// Send signal
127126
// TODO: Implement -q
128127
let echo = matches.get_flag("echo");
128+
#[cfg(unix)]
129129
kill(&pids, sig, echo);
130130

131131
if matches.get_flag("count") {
@@ -304,7 +304,7 @@ fn parse_signal_value(signal_name: &str) -> UResult<usize> {
304304
}
305305
}
306306

307-
#[cfg(target_os = "linux")]
307+
#[cfg(unix)]
308308
fn kill(pids: &Vec<ProcessInformation>, sig: Option<Signal>, echo: bool) {
309309
for pid in pids {
310310
if let Err(e) = signal::kill(Pid::from_raw(pid.pid as i32), sig) {
@@ -320,25 +320,6 @@ fn kill(pids: &Vec<ProcessInformation>, sig: Option<Signal>, echo: bool) {
320320
}
321321
}
322322

323-
#[cfg(target_os = "macos")]
324-
fn kill(pids: &Vec<ProcessInformation>, sig: Option<Signal>, echo: bool) {
325-
for pid in pids {
326-
if let Err(e) = signal::kill(Pid::from_raw(pid.pid as i32), sig) {
327-
show!(Error::from_raw_os_error(e as i32)
328-
.map_err_context(|| format!("killing pid {} failed", pid.pid)));
329-
} else if echo {
330-
println!(
331-
"{} killed (pid {})",
332-
pid.cmdline.split(" ").next().unwrap_or(""),
333-
pid.pid
334-
);
335-
}
336-
}
337-
}
338-
339-
#[cfg(target_os = "windows")]
340-
fn kill(pids: &Vec<ProcessInformation>, sig: Option<Signal>, echo: bool) {}
341-
342323
#[allow(clippy::cognitive_complexity)]
343324
pub fn uu_app() -> Command {
344325
Command::new(uucore::util_name())

0 commit comments

Comments
 (0)