Skip to content

Conversation

@amuhametov
Copy link

Gracefully close open descriptors

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.

}
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