mirror of https://github.com/mkerrisk/man-pages
ferror.3: Warn about closing the result of fileno()
Since adding checking to Android's bionic for file descriptor double-closes, we've found that the most common cause of these bugs is incorrect use of fileno(3). There appears to be a common misconception that it transfers ownership of the file descriptor to the caller. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
b79b66d119
commit
c36a6bedf6
|
@ -89,7 +89,15 @@ The function
|
|||
.BR fileno ()
|
||||
examines the argument
|
||||
.I stream
|
||||
and returns its integer file descriptor.
|
||||
and returns the integer file descriptor used to implement this stream.
|
||||
The file descriptor is still owned by
|
||||
.I stream
|
||||
and will be closed when
|
||||
.BR fclose (3)
|
||||
is called.
|
||||
Duplicate the file descriptor with
|
||||
.BR dup (2)
|
||||
before passing it to code that might close it.
|
||||
.PP
|
||||
For nonlocking counterparts, see
|
||||
.BR unlocked_stdio (3).
|
||||
|
|
Loading…
Reference in New Issue