-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Handle vanishing PIDs #1043
Handle vanishing PIDs #1043
Conversation
ec73c90
to
dc49974
Compare
PIDs can vanish (exit) from /proc/ between gathering the list of PIDs and getting all of their stats. * Ignore file not found errors. * Explicitly count the PIDs we find. * Cleanup some error style issues. Signed-off-by: Ben Kochie <superq@gmail.com>
dc49974
to
0c42334
Compare
👍 |
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.
LGTM
thread := 0 | ||
procStates := make(map[string]int32) | ||
for _, pid := range p { | ||
stat, err := pid.NewStat() | ||
// PIDs can vanish between getting the list and getting stats. | ||
if os.IsNotExist(err) { | ||
log.Debugf("file not found when retrieving stats: %q", err) |
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.
Just use %s
or %v
for error
type formatting (but %q
is good to quote file names embedded in a string).
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.
This is an issue all over the codebase. I filed #1044 to do cleanup.
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.
It seems like all the other %q
I found are legit - %q
makes sense when you actually want to quote something, but when you have a final colon and then an entire error string following, it doesn't make sense to quote that.
PIDs can vanish (exit) from /proc/ between gathering the list of PIDs and getting all of their stats. * Ignore file not found errors. * Explicitly count the PIDs we find. * Cleanup some error style issues. Signed-off-by: Ben Kochie <superq@gmail.com>
PIDs can vanish (exit) from /proc/ between gathering the list of PIDs
and getting all of their stats.
Fixes: #1042
Signed-off-by: Ben Kochie superq@gmail.com