3 ms·
The snippet in the first update is very wrong. The manpage for Linux’s implementation of close() explicitly says that it should not be called again if it fails
by cccbbbaaa 2y ago
The snippet in the first update is very wrong. The manpage for Linux’s implementation of close() explicitly says that it should not be called again if it fails. Apparently, this is the same under FreeBSD.
- klodolph 2y agoThe implementation of `os.File.Close()` in Go clears the file descriptor. https://pkg.go.dev/os#File.Close https://pkg.go.dev/os#File.Close “Close will return an error if it has already been called.” An os.File is a data structure containing a file descriptor and some other fields. It is safe to call Close() multiple times, because it will only call the underlying syscall close() once.