]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/fileno.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / fileno.3
CommitLineData
acd8a0e3
MK
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.
4.\"
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.
8.\"
47009d5e 9.\" SPDX-License-Identifier: BSD-4-Clause-UC
acd8a0e3
MK
10.\"
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
13.\"
4c1c5274 14.TH fileno 3 (date) "Linux man-pages (unreleased)"
acd8a0e3
MK
15.SH NAME
16fileno \- obtain file descriptor of a stdio stream
cfba38f4
AC
17.SH LIBRARY
18Standard C library
19.RI ( libc ", " \-lc )
acd8a0e3
MK
20.SH SYNOPSIS
21.nf
22.B #include <stdio.h>
23.PP
24.BI "int fileno(FILE *" stream );
25.fi
26.PP
27.RS -4
28Feature Test Macro Requirements for glibc (see
29.BR feature_test_macros (7)):
30.RE
31.PP
32.BR fileno ():
33.nf
34 _POSIX_C_SOURCE
35.fi
36.SH DESCRIPTION
acd8a0e3
MK
37The function
38.BR fileno ()
39examines the argument
40.I stream
41and returns the integer file descriptor used to implement this stream.
42The file descriptor is still owned by
43.I stream
44and will be closed when
45.BR fclose (3)
46is called.
47Duplicate the file descriptor with
48.BR dup (2)
49before passing it to code that might close it.
50.PP
51For the nonlocking counterpart, see
52.BR unlocked_stdio (3).
53.SH RETURN VALUE
54On success,
55.BR fileno ()
56returns the file descriptor associated with
57.IR stream .
58On failure, \-1 is returned and
59.I errno
60is set to indicate the error.
61.SH ERRORS
62.TP
63.B EBADF
64.I stream
65is not associated with a file.
66.SH ATTRIBUTES
67For an explanation of the terms used in this section, see
68.BR attributes (7).
69.ad l
70.nh
71.TS
72allbox;
73lbx lb lb
74l l l.
75Interface Attribute Value
76T{
77.BR fileno ()
78T} Thread safety MT-Safe
79.TE
80.hy
81.ad
82.sp 1
3113c7f3 83.SH STANDARDS
acd8a0e3
MK
84The function
85.BR fileno ()
86conforms to POSIX.1-2001 and POSIX.1-2008.
87.SH SEE ALSO
88.BR open (2),
89.BR fdopen (3),
90.BR stdio (3),
91.BR unlocked_stdio (3)