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