Skip to content

ensure all fd closed#7

Open
amuhametov wants to merge 4 commits into
cakturk:masterfrom
amuhametov:master
Open

ensure all fd closed#7
amuhametov wants to merge 4 commits into
cakturk:masterfrom
amuhametov:master

Conversation

@amuhametov

Copy link
Copy Markdown

Gracefully close open descriptors

Comment thread netstat/netstat_linux.go
z := bytes.SplitN(buf[:n], []byte(" "), 3)
name := getProcName(z[1])
p.p = &Process{p.pid, name}
stat.Close()

Copy link
Copy Markdown
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.

Comment thread netstat/netstat_linux.go
}
tabs, err := parseSocktab(f, fn)
f.Close()
if err != nil {

Copy link
Copy Markdown
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