-
Notifications
You must be signed in to change notification settings - Fork 67
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
ensure all fd closed #7
base: master
Are you sure you want to change the base?
Conversation
if err != nil { | ||
return | ||
} | ||
z := bytes.SplitN(buf[:n], []byte(" "), 3) | ||
name := getProcName(z[1]) | ||
p.p = &Process{p.pid, name} | ||
stat.Close() |
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.
What happens, do you think, if stat.Read()
fails? You would end up with an open
file descriptor.
if err != nil { | ||
return nil, err | ||
} | ||
tabs, err := parseSocktab(f, fn) | ||
f.Close() | ||
if err != nil { |
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.
Sorry, but, you're missing the point that you should only close file descriptors that
opened successfully.
Gracefully close open descriptors