diff options
| author | Elliot Hughes <enh@google.com> | 2018-10-01 10:33:21 -0700 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2018-11-05 16:50:52 +0100 |
| commit | c36a6bedf681884a3278e1b9f46108e22e5f238c (patch) | |
| tree | 33c28fe952341c6ae40a4b8348a3f26a65639c61 | |
| parent | b79b66d1192e19d8b279168c67279889cdc30184 (diff) | |
| download | man-pages-c36a6bedf681884a3278e1b9f46108e22e5f238c.tar.gz | |
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>
| -rw-r--r-- | man3/ferror.3 | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/man3/ferror.3 b/man3/ferror.3 index b45eb5559d..609e10cf8d 100644 --- a/man3/ferror.3 +++ b/man3/ferror.3 @@ -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). |
