-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: return value of Fd can be closed unexpectedly by finalizer #9046
Labels
Milestone
Comments
I agree that the problem is that tty is not live. The *os.File to which it points is eventually collected, and the finalizer closes the file descriptor. There is nothing keeping tty live, so it is hard to blame the compiler. This would be more obvious if the function were func ttyFd() uintptr { tty, _ := os.Open("/dev/tty") return tty.Fd() } I think our choices are 1) document that you must be careful to keep the *os.File live if you call the Fd method; 2) have the Fd method clear the finalizer, and document that the caller of Fd is responsible for closing the descriptor, somehow--actually this would probably require adding a new function to close a descriptor. Labels changed: added release-go1.4maybe, removed release-go1.4. |
CL https://golang.org/cl/162680043 mentions this issue. |
This issue was closed by revision 1cdd9b4. Status changed to Fixed. |
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 25, 2018
Fixes golang#9046. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/162680043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 26, 2018
Fixes golang#9046. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/162680043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
Fixes golang#9046. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/162680043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 20, 2018
Fixes golang#9046. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/162680043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 30, 2018
Fixes golang#9046. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/162680043
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by 2852914@wessie.info:
The text was updated successfully, but these errors were encountered: