1FILENO(3P) POSIX Programmer's Manual FILENO(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 fileno — map a stream pointer to a file descriptor
13
15 #include <stdio.h>
16
17 int fileno(FILE *stream);
18
20 The fileno() function shall return the integer file descriptor associ‐
21 ated with the stream pointed to by stream.
22
24 Upon successful completion, fileno() shall return the integer value of
25 the file descriptor associated with stream. Otherwise, the value -1
26 shall be returned and errno set to indicate the error.
27
29 The fileno() function shall fail if:
30
31 EBADF The stream is not associated with a file.
32
33 The fileno() function may fail if:
34
35 EBADF The file descriptor underlying stream is not a valid file
36 descriptor.
37
38 The following sections are informative.
39
41 None.
42
44 None.
45
47 Without some specification of which file descriptors are associated
48 with these streams, it is impossible for an application to set up the
49 streams for another application it starts with fork() and exec. In
50 particular, it would not be possible to write a portable version of the
51 sh command interpreter (although there may be other constraints that
52 would prevent that portability).
53
55 None.
56
58 Section 2.5.1, Interaction of File Descriptors and Standard I/O
59 Streams, dirfd(), fdopen(), fopen(), stdin
60
61 The Base Definitions volume of POSIX.1‐2017, <stdio.h>
62
64 Portions of this text are reprinted and reproduced in electronic form
65 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
66 table Operating System Interface (POSIX), The Open Group Base Specifi‐
67 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
68 Electrical and Electronics Engineers, Inc and The Open Group. In the
69 event of any discrepancy between this version and the original IEEE and
70 The Open Group Standard, the original IEEE and The Open Group Standard
71 is the referee document. The original Standard can be obtained online
72 at http://www.opengroup.org/unix/online.html .
73
74 Any typographical or formatting errors that appear in this page are
75 most likely to have been introduced during the conversion of the source
76 files to man page format. To report such errors, see https://www.ker‐
77 nel.org/doc/man-pages/reporting_bugs.html .
78
79
80
81IEEE/The Open Group 2017 FILENO(3P)