-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkill: implement #290
pkill: implement #290
Conversation
Great start. Could you please add tests? |
Yes, any advice? |
And also, more unit tests would be better. If it cannot run on Windows, you can disable it for Windows simply. eg. #[cfg(target_os = "linux")]
#[test]
fn test_something() {
...
} At least you can write unit tests about parsing arguments? |
Could you please fix the CI failures?
|
I think this file will help you to be compatible with macOS and other *NIX implementations. https://github.com/uutils/coreutils/blob/main/src/uucore/src/lib/features/signals.rs The Windows implementation much different with *NIX implementation, so you can simply disable it. #[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
fn do_something(){}
#[cfg(not(target_family = "unix"))]
fn do_something(){} |
Behavior seems doesn't match
|
#[cfg(unix)] | ||
let sig_num = if let Some(signal) = obs_signal { | ||
signal | ||
} else if let Some(signal) = matches.get_one::<String>("signal") { | ||
parse_signal_value(signal)? | ||
} else { | ||
15_usize //SIGTERM | ||
}; | ||
|
||
#[cfg(unix)] | ||
let sig_name = signal_name_by_value(sig_num); | ||
// Signal does not support converting from EXIT | ||
// Instead, nix::signal::kill expects Option::None to properly handle EXIT | ||
#[cfg(unix)] | ||
let sig: Option<Signal> = if sig_name.is_some_and(|name| name == "EXIT") { | ||
None | ||
} else { | ||
let sig = (sig_num as i32) | ||
.try_into() | ||
.map_err(|e| std::io::Error::from_raw_os_error(e as i32))?; | ||
Some(sig) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap as block
#[cfg(unix)] | ||
let echo = matches.get_flag("echo"); | ||
#[cfg(unix)] | ||
kill(&pids, sig, echo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, or a function
fells confusing, the implementation should be correct but the behavior not. could you give some help? @sylvestre @cakebaker |
do you have details ? |
Here's the details |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #290 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. |
#27