summaryrefslogtreecommitdiffstats
path: root/man2/close.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/close.2')
-rw-r--r--man2/close.244
1 files changed, 22 insertions, 22 deletions
diff --git a/man2/close.2 b/man2/close.2
index cc6d2f43e..365ccb628 100644
--- a/man2/close.2
+++ b/man2/close.2
@@ -30,14 +30,14 @@ Standard C library
closes a file descriptor, so that it no longer refers to any file and
may be reused.
Any record locks (see
-.BR fcntl (2))
+.MR fcntl 2 )
held on the file it was associated with,
and owned by the process,
are removed regardless of the file descriptor that was used to obtain the lock.
This has some unfortunate consequences
and one should be extra careful when using advisory record locking.
See
-.BR fcntl (2)
+.MR fcntl 2
for discussion of the risks and consequences
as well as for the (probably preferred) open file description locks.
.P
@@ -45,11 +45,11 @@ If
.I fd
is the last file descriptor referring to the underlying
open file description (see
-.BR open (2)),
+.MR open 2 ),
the resources associated with the open file description are freed;
if the file descriptor was the last reference to a file which has been
removed using
-.BR unlink (2),
+.MR unlink 2 ,
the file is deleted.
.SH RETURN VALUE
.BR close ()
@@ -69,7 +69,7 @@ isn't a valid open file descriptor.
The
.BR close ()
call was interrupted by a signal; see
-.BR signal (7).
+.MR signal 7 .
.TP
.B EIO
An I/O error occurred.
@@ -80,8 +80,8 @@ An I/O error occurred.
On NFS, these errors are not normally reported against the first write
which exceeds the available storage space, but instead against a
subsequent
-.BR write (2),
-.BR fsync (2),
+.MR write 2 ,
+.MR fsync 2 ,
or
.BR close ().
.P
@@ -99,14 +99,14 @@ saved to disk, as the kernel uses the buffer cache to defer writes.
Typically, filesystems do not flush buffers when a file is closed.
If you need to be sure that
the data is physically stored on the underlying disk, use
-.BR fsync (2).
+.MR fsync 2 .
(It will depend on the disk hardware at this point.)
.P
The close-on-exec file descriptor flag can be used to ensure
that a file descriptor is automatically closed upon a successful
-.BR execve (2);
+.MR execve 2 ;
see
-.BR fcntl (2)
+.MR fcntl 2
for details.
.\"
.SS Multithreaded processes and close()
@@ -130,9 +130,9 @@ performing operations on the same file descriptor:
.IP (1) 5
One thread is blocked in an I/O system call on the file descriptor.
For example, it is trying to
-.BR write (2)
+.MR write 2
to a pipe that is already full, or trying to
-.BR read (2)
+.MR read 2
from a stream socket which currently has no available data.
.IP (2)
Another thread closes the file descriptor.
@@ -147,7 +147,7 @@ open file description, and this reference keeps the description open
until the I/O system call completes.
.\" 'struct file' in kernel-speak
(See
-.BR open (2)
+.MR open 2
for a discussion of open file descriptions.)
Thus, the blocking system call in the first thread may successfully
complete after the
@@ -158,7 +158,7 @@ in the second thread.
A careful programmer will check the return value of
.BR close (),
since it is quite possible that errors on a previous
-.BR write (2)
+.MR write 2
operation are reported only on the final
.BR close ()
that releases the open file description.
@@ -210,7 +210,7 @@ of the standard.
A careful programmer who wants to know about I/O errors may precede
.BR close ()
with a call to
-.BR fsync (2).
+.MR fsync 2 .
.P
The
.B EINTR
@@ -265,10 +265,10 @@ the next major release of the POSIX.1 standard.
.\" Review the following glibc bug later
.\" https://sourceware.org/bugzilla/show_bug.cgi?id=14627
.SH SEE ALSO
-.BR close_range (2),
-.BR fcntl (2),
-.BR fsync (2),
-.BR open (2),
-.BR shutdown (2),
-.BR unlink (2),
-.BR fclose (3)
+.MR close_range 2 ,
+.MR fcntl 2 ,
+.MR fsync 2 ,
+.MR open 2 ,
+.MR shutdown 2 ,
+.MR unlink 2 ,
+.MR fclose 3