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

Close opened fd #493

Merged
merged 1 commit into from
Oct 19, 2021
Merged

Close opened fd #493

merged 1 commit into from
Oct 19, 2021

Conversation

jschwinger233
Copy link
Member

实际操作和观察了一下, 其实好像并没有 fd 泄露, 这是因为 newFile 里注册了 runtime.SetFinalizer(f.file, (*file).close), 所以会在 gc 的时候自动 close...

不过 explicit 肯定好于 implicit, 我还是加上.

源码可以看: os/unix_file.go

@CMGS CMGS merged commit 2bb6646 into projecteru2:master Oct 19, 2021
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