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

ensure all fd closed #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

amuhametov
Copy link

Gracefully close open descriptors

if err != nil {
return
}
z := bytes.SplitN(buf[:n], []byte(" "), 3)
name := getProcName(z[1])
p.p = &Process{p.pid, name}
stat.Close()
Copy link
Owner

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 {
Copy link
Owner

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.

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