Skip to content

Fix cpu_info bug #341

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

Merged
merged 1 commit into from
May 17, 2025
Merged

Conversation

aaronkollasch
Copy link
Contributor

Grepping the output of top for Cpu(s) includes a row for the grep "Cpu(s)" process, which sometimes ends up being selected by tail -1, causing a nonsensical %CPU reading (in orange in the screenshot below).

Screenshot 2025-05-16 at 2 22 58 AM

This fix uses the pattern [C]pu(s) to exclude the search pattern in the grep process itself, a la this stackexchange https://unix.stackexchange.com/a/74186.
Screenshot 2025-05-16 at 2 24 47 AM

It is still possible for the grep pattern to match Cpu(s) in the arguments for another process, but that seems much less likely.

Grepping the output of top could sometimes return the grep process,
leading to a nonsensical %CPU reading.
@ethancedwards8 ethancedwards8 merged commit fa2e59b into dracula:master May 17, 2025
1 check passed
@ethancedwards8
Copy link
Member

Nice catch. Thanks.

@aaronkollasch aaronkollasch deleted the fix-cpu-info branch May 17, 2025 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants