From: Paolo Ornati <ornati@fastwebnet.it>
To: Linus Torvalds <torvalds@osdl.org>
Cc: "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@yahoo.it>,
Jeff Dike <jdike@addtoit.com>,
LKML <linux-kernel@vger.kernel.org>,
user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [patch 7/7] uml: retry host close() on EINTR
Date: Sun, 11 Sep 2005 09:28:02 +0200 [thread overview]
Message-ID: <20050911092802.1ab931ac@localhost> (raw)
In-Reply-To: <Pine.LNX.4.58.0509101157170.30958@g5.osdl.org>
On Sat, 10 Sep 2005 12:00:01 -0700 (PDT)
Linus Torvalds <torvalds@osdl.org> wrote:
> Re-doing the close() is the wrong thing to do, since in a threaded
> environment, something else might have opened another file, gotten
> the same file descriptor, and you now close _another_ file.
So glibc doc is wrong here:
http://www.gnu.org/software/libc/manual/html_node/Opening-and-Closing-Files.html#index-close-1197
-----------------------------------------------------------------------
The normal return value from close is 0; a value of -1 is returned in
case of failure. The following errno error conditions are defined for
this function:
...
EINTR
The close call was interrupted by a signal. See Interrupted
Primitives. Here is an example of how to handle EINTR properly:
TEMP_FAILURE_RETRY (close (desc));
-----------------------------------------------------------------------
And: /usr/include/unistd.h
# define TEMP_FAILURE_RETRY(expression) \
(__extension__ \
({ long int __result; \
do __result = (long int) (expression); \
while (__result == -1L && errno == EINTR); \
__result; }))
#endif
SUSV3:
-------------------------------------------------------------
If close() is interrupted by a signal that is to be caught, it shall
return -1 with errno set to [EINTR] and the state of fildes is
unspecified
-------------------------------------------------------------
Unspecified! ;-)
--
Paolo Ornati
Linux 2.6.13.1 on x86_64
next prev parent reply other threads:[~2005-09-11 7:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 1/7] Uml: more cleaning Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 2/7] i386 / uml: add dwarf sections to static link script Paolo 'Blaisorblade' Giarrusso
2005-09-10 18:38 ` Sam Ravnborg
2005-09-10 17:44 ` [patch 3/7] x86_64 linker script cleanups for debug sections Paolo 'Blaisorblade' Giarrusso
2005-09-12 5:52 ` Andi Kleen
2005-09-13 17:56 ` Blaisorblade
2005-09-10 17:44 ` [patch 4/7] uml: inline mk_pte and various friends Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 5/7] uml: fix fault handler on write Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 6/7] uml: avoid already done dirtying Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 7/7] uml: retry host close() on EINTR Paolo 'Blaisorblade' Giarrusso
2005-09-10 19:00 ` Linus Torvalds
2005-09-11 7:28 ` Paolo Ornati [this message]
2005-09-11 11:49 ` Linus Torvalds
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=20050911092802.1ab931ac@localhost \
--to=ornati@fastwebnet.it \
--cc=blaisorblade@yahoo.it \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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