1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" and Copyright (C) 2021 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Chris Torek and the American National Standards Committee X3,
7 .\" on Information Processing Systems.
9 .\" SPDX-License-Identifier: BSD-4-Clause-UC
11 .\" Converted for Linux, Mon Nov 29 14:24:40 1993, faith@cs.unc.edu
12 .\" Added remark on EBADF for fileno, aeb, 2001-03-22
14 .TH FILENO 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
16 fileno \- obtain file descriptor of a stdio stream
19 .RI ( libc ", " \-lc )
24 .BI "int fileno(FILE *" stream );
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
41 and returns the integer file descriptor used to implement this stream.
42 The file descriptor is still owned by
44 and will be closed when
47 Duplicate the file descriptor with
49 before passing it to code that might close it.
51 For the nonlocking counterpart, see
52 .BR unlocked_stdio (3).
56 returns the file descriptor associated with
58 On failure, \-1 is returned and
60 is set to indicate the error.
65 is not associated with a file.
67 For an explanation of the terms used in this section, see
75 Interface Attribute Value
78 T} Thread safety MT-Safe
86 conforms to POSIX.1-2001 and POSIX.1-2008.
91 .BR unlocked_stdio (3)