6 ms·
Quoting from "man 2 close": https://man7.org/linux/man-pages/man2/close.2.html https://man7.org/linux/man-pages/man2/close.2.html > it is quite possible that e
by TheDong 4y ago
Quoting from "man 2 close": https://man7.org/linux/man-pages/man2/close.2.html https://man7.org/linux/man-pages/man2/close.2.html
> it is quite possible that errors on a previous write(2) operation are reported only on the final close() ... Failing to check the return value when closing a file may lead to silent loss of data.
> the behavior that occurs on Linux ... the file descriptor is guaranteed to be closed.
So yeah, it's always closed on linux, but POSIX doesn't guarantee that for EINTR specifically, and there are sometimes meaningful errors.
- lilyball 4y agoFWIW Rust automatically retries the operation on EINTR.
- dllthomas 4y ago> Failing to check the return value when closing a file may lead to silent loss of data. Checking, on the other hand, probably makes it loud loss of data.
- turminal 4y agoWhy would it? If you care enough to check you probably also care enough not to discard the data you attempted to write.
- dllthomas 4y agoI was referring to checking because "you should check" when you don't actually care enough to structure your program around not losing the data. It's easy to to check and emit a diagnostic, it's harder to make sure you have collected the data you've written to a file descriptor and have something sensible to do with it if the close fails.