Skip to content
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

Implement chcpu #226

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Implement chcpu #226

wants to merge 10 commits into from

Conversation

alxndrv
Copy link
Contributor

@alxndrv alxndrv commented Feb 17, 2025

This PR implements pretty much the entirety of chcpu.

Some things still missing:

  • Tests: I'm not entirely sure how to properly test something which is so tightly coupled to system internals.
  • Exit codes: chcpu should return a non-zero exit code in some edge cases. This implementation does check for most such cases, but pretty much always returns a success exit-code. I'm guessing that uucore::error::UResult can be used to solve this somehow without having to manually call std::process::exit().

@alxndrv alxndrv marked this pull request as ready for review February 17, 2025 16:44
@sylvestre
Copy link
Contributor

in general, to test such things, you either try to mock up
and you do your best to look at the error management

@alxndrv
Copy link
Contributor Author

alxndrv commented Feb 17, 2025

@sylvestre Thanks for the review, I'll implement your suggestions a bit later. Since we're on the topic of deduping: there's some code here that's copy-pasted from my work on lscpu (the parse_cpu_list() function). Should there be some kind of "lib" crate for common stuff like this? These kinds of CPU lists come up in a bunch of Linux utils and theres no sense in implementing it all over again every time. There's other similar examples: for example the mount-related utils all have to parse mount entries from /proc/<pid>/mountinfo and could benefit from having a shared lib.

@koutheir koutheir mentioned this pull request Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants