From: Florian Weimer <fw@deneb.enyo.de>
To: "Zack Weinberg" <zack@owlfolio.org>
Cc: "Alejandro Colomar" <alx@kernel.org>,
"Rich Felker" <dalias@libc.org>,
"Vincent Lefevre" <vincent@vinc17.net>,
"Jan Kara" <jack@suse.cz>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org,
"GNU libc development" <libc-alpha@sourceware.org>
Subject: Re: [RFC v1] man/man2/close.2: CAVEATS: Document divergence from POSIX.1-2024
Date: Sat, 24 May 2025 21:25:07 +0200 [thread overview]
Message-ID: <871psdlsks.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <8c47e10a-be82-4d5b-a45e-2526f6e95123@app.fastmail.com> (Zack Weinberg's message of "Fri, 23 May 2025 14:10:57 -0400")
* Zack Weinberg:
> BUGS
> Prior to POSIX.1-2024, there was no official guarantee that
> close() would always close the file descriptor, even on error.
> Linux has always closed the file descriptor, even on error,
> but other implementations might not have.
>
> The only such implementation we have heard of is HP-UX; at least
> some versions of HP-UX’s man page for close() said it should be
> retried if it returned -1 with errno set to EINTR. (If you know
> exactly which versions of HP-UX are affected, or of any other
> Unix where close() doesn’t always close the file descriptor,
> please contact us about it.)
The AIX documentation also says this:
| The success of the close subroutine is undetermined if the following
| is true:
|
| EINTR The state of the FileDescriptor is undetermined. Retry the
| close routine to ensure that the FileDescriptor is closed.
<https://www.ibm.com/docs/en/aix/7.2.0?topic=c-close-subroutine>
So it's not just HP-UX.
For z/OS, it looks like some other errors leave the descriptor open:
| EAGAIN
|
| The call did not complete because the specified socket descriptor
| is currently being used by another thread in the same process.
|
| For example, in a multithreaded environment, close() fails and
| returns EAGAIN when the following sequence of events occurs (1)
| thread is blocked in a read() or select() call on a given file or
| socket descriptor and (2) another thread issues a simultaneous
| close() call for the same descriptor.
| […]
| EBADF
| fildes is not a valid open file descriptor, or the socket
| parameter is not a valid socket descriptor.
<https://www.ibm.com/docs/en/zos/2.1.0?topic=functions-close-close-file>
next prev parent reply other threads:[~2025-05-24 19:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 21:33 close(2) with EINTR has been changed by POSIX.1-2024 Alejandro Colomar
2025-05-16 10:48 ` Jan Kara
2025-05-16 12:11 ` Alejandro Colomar
2025-05-16 12:52 ` [RFC v1] man/man2/close.2: CAVEATS: Document divergence from POSIX.1-2024 Alejandro Colomar
2025-05-16 13:05 ` Rich Felker
2025-05-16 14:20 ` Theodore Ts'o
2025-05-17 5:46 ` Alejandro Colomar
2025-05-17 13:03 ` Alejandro Colomar
2025-05-17 13:43 ` Rich Felker
2025-05-16 14:39 ` Vincent Lefevre
2025-05-16 14:52 ` Florian Weimer
2025-05-16 15:28 ` Vincent Lefevre
2025-05-16 15:28 ` Rich Felker
2025-05-17 13:32 ` Rich Felker
2025-05-17 13:46 ` Alejandro Colomar
2025-05-23 18:10 ` Zack Weinberg
2025-05-24 2:24 ` Rich Felker
2025-05-24 19:25 ` Florian Weimer [this message]
2025-05-16 12:41 ` close(2) with EINTR has been changed by POSIX.1-2024 Mateusz Guzik
2025-05-16 12:41 ` Theodore Ts'o
2025-05-19 23:19 ` Steffen Nurpmeso
2025-05-20 13:37 ` Theodore Ts'o
2025-05-20 23:16 ` Steffen Nurpmeso
2025-05-16 19:13 ` Al Viro
2025-05-19 9:48 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871psdlsks.fsf@mid.deneb.enyo.de \
--to=fw@deneb.enyo.de \
--cc=alx@kernel.org \
--cc=brauner@kernel.org \
--cc=dalias@libc.org \
--cc=jack@suse.cz \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=vincent@vinc17.net \
--cc=viro@zeniv.linux.org.uk \
--cc=zack@owlfolio.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).