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
19
21 The fileno() function shall return the integer file descriptor associ‐
22 ated with the stream pointed to by stream.
23
25 Upon successful completion, fileno() shall return the integer value of
26 the file descriptor associated with stream. Otherwise, the value -1
27 shall be returned and errno set to indicate the error.
28
30 The fileno() function may fail if:
31
32 EBADF The stream argument is not a valid stream.
33
34
35 The following sections are informative.
36
38 None.
39
41 None.
42
44 Without some specification of which file descriptors are associated
45 with these streams, it is impossible for an application to set up the
46 streams for another application it starts with fork() and exec. In par‐
47 ticular, it would not be possible to write a portable version of the sh
48 command interpreter (although there may be other constraints that would
49 prevent that portability).
50
52 None.
53
55 Interaction of File Descriptors and Standard I/O Streams, fdopen(),
56 fopen(), stdin(), the Base Definitions volume of IEEE Std 1003.1-2001,
57 <stdio.h>
58
60 Portions of this text are reprinted and reproduced in electronic form
61 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
62 -- Portable Operating System Interface (POSIX), The Open Group Base
63 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
64 Electrical and Electronics Engineers, Inc and The Open Group. In the
65 event of any discrepancy between this version and the original IEEE and
66 The Open Group Standard, the original IEEE and The Open Group Standard
67 is the referee document. The original Standard can be obtained online
68 at http://www.opengroup.org/unix/online.html .
69
70
71
72IEEE/The Open Group 2003 FILENO(3P)