Skip to content

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