Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #506 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implements taskset(1) with hex mask and CPU list parsing/formatting, -p (pid mode), -a (all-tasks), and exec mode. Includes stride notation in format_cpu_list, comma-separated hex mask support from /proc/<pid>/status, and unit + integration tests.
|
Ping. @sylvestre |
| // For the full copyright and license information, please view the LICENSE | ||
| // file that was distributed with this source code. | ||
|
|
||
| #![cfg_attr(not(target_os = "linux"), allow(dead_code, unused_imports))] |
There was a problem hiding this comment.
please don't silence this with allow, cfg the unused bits instead
| println!("pid {}'s current {}: {}", p, label, fmt(&set)); | ||
| } | ||
| } | ||
| [mask_str, pid_str, ..] => { |
There was a problem hiding this comment.
.. silently accepts taskset -p mask pid extra, util-linux rejects it, no?
| } else { | ||
| vec![pid] | ||
| }; | ||
| for p in pids { |
There was a problem hiding this comment.
almost the same loop as the one above (pids + getaffinity + ESRCH), could be dedup, no?
| // exec() replaces the current process image and never returns | ||
| // on success; if it returns at all, it's an error. | ||
| let err = std::process::Command::new(command).args(rest).exec(); | ||
| return Err(err.map_err_context(|| format!("failed to execute {command}"))); |
There was a problem hiding this comment.
util-linux exits with 127 when the command is not found and 126 for other exec failures, not 1.
could you please match that and update test_command_not_found?
|
|
||
| #[cfg(target_os = "linux")] | ||
| fn format_hex_mask(set: &CpuSet) -> String { | ||
| let max_cpu = (0..CpuSet::count()).rev().find(|&i| set.is_set(i).unwrap()); |
There was a problem hiding this comment.
please avoid the unwrap() here and at line 312
format!("{:x}") on the nibble would be simpler
| ranges.push(format!("{}-{}", a, b)); | ||
| i = j + 1; | ||
| } else { | ||
| ranges.push(format!("{}-{}:{}", a, b, step)); |
There was a problem hiding this comment.
as far as i know, util-linux taskset -cp never prints stride notation: for 0,2,4 it prints 0,2,4, not 0-4:2.
could you please check against the real taskset and match it?
| .args(&["-c", "0", "/usr/bin/true"]) | ||
| .succeeds() | ||
| .no_output(); | ||
| } |
There was a problem hiding this comment.
these exec tests only check that it doesn't fail
could you please run something like cat /proc/self/status and assert that Cpus_allowed_list matches?
also please use true rather than /usr/bin/true, it isn't there on every system
Implements taskset(1) with hex mask and CPU list parsing/formatting, -p (pid mode), -a (all-tasks), and exec mode. Includes stride notation in format_cpu_list, comma-separated hex mask support from /proc//status, and unit + integration tests.