mirror of https://github.com/mkerrisk/man-pages
Add text cautioning about use of close() in
multithreaded programs.
This commit is contained in:
parent
0a1a55e0b1
commit
aadd727c4f
15
man2/close.2
15
man2/close.2
|
@ -104,6 +104,21 @@ If you need to be sure that
|
|||
the data is physically stored use
|
||||
.BR fsync (2).
|
||||
(It will depend on the disk hardware at this point.)
|
||||
.PP
|
||||
It is probably unwise to close file descriptors while
|
||||
they may be in use by system calls in
|
||||
other threads in the same process.
|
||||
Since a file descriptor may be re-used,
|
||||
there are some obscure race conditions
|
||||
that may cause unintended side effects.
|
||||
.\" Date: Tue, 4 Sep 2007 13:57:35 +0200
|
||||
.\" From: Fredrik Noring <noring@nocrew.org>
|
||||
.\" One such race involves signals and ERESTARTSYS. If a file descriptor
|
||||
.\" in use by a system call is closed and then reused by e.g. an
|
||||
.\" independet open() in some unrelated thread, before the original system
|
||||
.\" call has restared after ERESTARTSYS, the original system call will
|
||||
.\" later restart with the reused file descriptor. This is most likely a
|
||||
.\" serious programming error.
|
||||
.SH "SEE ALSO"
|
||||
.BR fcntl (2),
|
||||
.BR fsync (2),
|
||||
|
|
Loading…
Reference in New Issue