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 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. All advertising materials mentioning features or use of this software
19 .\" must display the following acknowledgement:
20 .\" This product includes software developed by the University of
21 .\" California, Berkeley and its contributors.
22 .\" 4. Neither the name of the University nor the names of its contributors
23 .\" may be used to endorse or promote products derived from this software
24 .\" without specific prior written permission.
26 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 .\" Converted for Linux, Mon Nov 29 14:24:40 1993, faith@cs.unc.edu
40 .\" Added remark on EBADF for fileno, aeb, 2001-03-22
42 .TH FILENO 3 2021-03-22 "" "Linux Programmer's Manual"
44 fileno \- obtain file descriptor of a stdio stream
49 .BI "int fileno(FILE *" stream );
53 Feature Test Macro Requirements for glibc (see
54 .BR feature_test_macros (7)):
67 and returns the integer file descriptor used to implement this stream.
68 The file descriptor is still owned by
70 and will be closed when
73 Duplicate the file descriptor with
75 before passing it to code that might close it.
77 For the nonlocking counterpart, see
78 .BR unlocked_stdio (3).
82 returns the file descriptor associated with
84 On failure, \-1 is returned and
86 is set to indicate the error.
91 is not associated with a file.
93 For an explanation of the terms used in this section, see
101 Interface Attribute Value
104 T} Thread safety MT-Safe
112 conforms to POSIX.1-2001 and POSIX.1-2008.
117 .BR unlocked_stdio (3)