]>
Commit | Line | Data |
---|---|---|
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 |
16 | fileno \- obtain file descriptor of a stdio stream | |
cfba38f4 AC |
17 | .SH LIBRARY |
18 | Standard 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 | |
28 | Feature 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 |
37 | The function |
38 | .BR fileno () | |
39 | examines the argument | |
40 | .I stream | |
41 | and returns the integer file descriptor used to implement this stream. | |
42 | The file descriptor is still owned by | |
43 | .I stream | |
44 | and will be closed when | |
45 | .BR fclose (3) | |
46 | is called. | |
47 | Duplicate the file descriptor with | |
48 | .BR dup (2) | |
49 | before passing it to code that might close it. | |
50 | .PP | |
51 | For the nonlocking counterpart, see | |
52 | .BR unlocked_stdio (3). | |
53 | .SH RETURN VALUE | |
54 | On success, | |
55 | .BR fileno () | |
56 | returns the file descriptor associated with | |
57 | .IR stream . | |
58 | On failure, \-1 is returned and | |
59 | .I errno | |
60 | is set to indicate the error. | |
61 | .SH ERRORS | |
62 | .TP | |
63 | .B EBADF | |
64 | .I stream | |
65 | is not associated with a file. | |
66 | .SH ATTRIBUTES | |
67 | For an explanation of the terms used in this section, see | |
68 | .BR attributes (7). | |
69 | .ad l | |
70 | .nh | |
71 | .TS | |
72 | allbox; | |
73 | lbx lb lb | |
74 | l l l. | |
75 | Interface Attribute Value | |
76 | T{ | |
77 | .BR fileno () | |
78 | T} Thread safety MT-Safe | |
79 | .TE | |
80 | .hy | |
81 | .ad | |
82 | .sp 1 | |
3113c7f3 | 83 | .SH STANDARDS |
acd8a0e3 MK |
84 | The function |
85 | .BR fileno () | |
86 | conforms 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) |