close.2: Note that errors from close() should be used only for diagnosis

In particular, retrying after EINTR is a bad idea.

See http://austingroupbugs.net/view.php?id=529

See http://thread.gmane.org/gmane.comp.lib.glibc.alpha/37702
Subject: [RFC][BZ #14627] Make linux close errno to EINPROGRESS
         when interrupted in signal.

Reported-by: P?draig Brady <P@draigBrady.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2013-12-30 22:30:04 +13:00
parent 8a7ac774ba
commit 445319fd4a
1 changed files with 7 additions and 1 deletions

View File

@ -32,7 +32,7 @@
.\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
.\" added note about close(2) not guaranteeing that data is safe on close.
.\"
.TH CLOSE 2 2007-12-28 "Linux" "Linux Programmer's Manual"
.TH CLOSE 2 2013-12-30 "Linux" "Linux Programmer's Manual"
.SH NAME
close \- close a file descriptor
.SH SYNOPSIS
@ -98,6 +98,12 @@ Not checking the return value when closing the file may lead to
silent loss of data.
This can especially be observed with NFS
and with disk quota.
Note that the return value should only be used for diagnostics.
In particular
.BR close ()
should not be retried after an
.B EINTR
since this may cause a reused descriptor from another thread to be closed.
.PP
A successful close does not guarantee that the data has been successfully
saved to disk, as the kernel defers writes.