1FILENO(3P)                 POSIX Programmer's Manual                FILENO(3P)
2
3
4

PROLOG

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
11

NAME

13       fileno — map a stream pointer to a file descriptor
14

SYNOPSIS

16       #include <stdio.h>
17
18       int fileno(FILE *stream);
19

DESCRIPTION

21       The fileno() function shall return the integer file descriptor  associ‐
22       ated with the stream pointed to by stream.
23

RETURN VALUE

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

ERRORS

30       The fileno() function may fail if:
31
32       EBADF  The  stream argument is not a valid stream, or the stream is not
33              associated with a file.
34
35       The following sections are informative.
36

EXAMPLES

38       None.
39

APPLICATION USAGE

41       None.
42

RATIONALE

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
47       particular, it would not be possible to write a portable version of the
48       sh command interpreter (although there may be  other  constraints  that
49       would prevent that portability).
50

FUTURE DIRECTIONS

52       None.
53

SEE ALSO

55       Section  2.5.1,  Interaction  of  File  Descriptors  and  Standard  I/O
56       Streams, dirfd(), fdopen(), fopen(), stdin
57
58       The Base Definitions volume of POSIX.1‐2008, <stdio.h>
59
61       Portions of this text are reprinted and reproduced in  electronic  form
62       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
63       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
64       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
65       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
66       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
67       event of any discrepancy between this version and the original IEEE and
68       The  Open Group Standard, the original IEEE and The Open Group Standard
69       is the referee document. The original Standard can be  obtained  online
70       at http://www.unix.org/online.html .
71
72       Any  typographical  or  formatting  errors that appear in this page are
73       most likely to have been introduced during the conversion of the source
74       files  to  man page format. To report such errors, see https://www.ker
75       nel.org/doc/man-pages/reporting_bugs.html .
76
77
78
79IEEE/The Open Group                  2013                           FILENO(3P)
Impressum