library: update comment around close()
This commit is contained in:
parent
5d3c6ee9b3
commit
729d3aa0fe
1 changed files with 11 additions and 10 deletions
|
@ -173,16 +173,17 @@ impl Drop for OwnedFd {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Note that errors are ignored when closing a file descriptor. The
|
// Note that errors are ignored when closing a file descriptor. According to POSIX 2024,
|
||||||
// reason for this is that if an error occurs we don't actually know if
|
// we can and indeed should retry `close` on `EINTR`
|
||||||
// the file descriptor was closed or not, and if we retried (for
|
// (https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/close.html),
|
||||||
// something like EINTR), we might close another valid file descriptor
|
// but it is not clear yet how well widely-used implementations are conforming with this
|
||||||
// opened after we closed ours.
|
// mandate since older versions of POSIX left the state of the FD after an `EINTR`
|
||||||
// However, this is usually justified, as some of the major Unices
|
// unspecified. Ignoring errors is "fine" because some of the major Unices (in
|
||||||
// do make sure to always close the FD, even when `close()` is interrupted,
|
// particular, Linux) do make sure to always close the FD, even when `close()` is
|
||||||
// and the scenario is rare to begin with.
|
// interrupted, and the scenario is rare to begin with. If we retried on a
|
||||||
// Helpful link to an epic discussion by POSIX workgroup:
|
// not-POSIX-compliant implementation, the consequences could be really bad since we may
|
||||||
// http://austingroupbugs.net/view.php?id=529
|
// close the wrong FD. Helpful link to an epic discussion by POSIX workgroup that led to
|
||||||
|
// the latest POSIX wording: http://austingroupbugs.net/view.php?id=529
|
||||||
#[cfg(not(target_os = "hermit"))]
|
#[cfg(not(target_os = "hermit"))]
|
||||||
{
|
{
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue