1FCLOSE(3)                  Linux Programmer's Manual                 FCLOSE(3)
2
3
4

NAME

6       fclose - close a stream
7

SYNOPSIS

9       #include <stdio.h>
10
11       int fclose(FILE *stream);
12

DESCRIPTION

14       The  fclose() function flushes the stream pointed to by stream (writing
15       any buffered output data using fflush(3))  and  closes  the  underlying
16       file descriptor.
17

RETURN VALUE

19       Upon  successful completion, 0 is returned.  Otherwise, EOF is returned
20       and errno is set to indicate the error.  In either  case,  any  further
21       access  (including  another  call to fclose()) to the stream results in
22       undefined behavior.
23

ERRORS

25       EBADF  The file descriptor underlying stream is not valid.
26
27       The fclose() function may also fail and set errno for any of the errors
28       specified for the routines close(2), write(2), or fflush(3).
29

ATTRIBUTES

31       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
32       tributes(7).
33
34       ┌────────────────────────────────────────────┬───────────────┬─────────┐
35Interface                                   Attribute     Value   
36       ├────────────────────────────────────────────┼───────────────┼─────────┤
37fclose()                                    │ Thread safety │ MT-Safe │
38       └────────────────────────────────────────────┴───────────────┴─────────┘
39

CONFORMING TO

41       POSIX.1-2001, POSIX.1-2008, C89, C99.
42

NOTES

44       Note that fclose() flushes only the user-space buffers provided by  the
45       C  library.   To  ensure that the data is physically stored on disk the
46       kernel buffers must be  flushed  too,  for  example,  with  sync(2)  or
47       fsync(2).
48

SEE ALSO

50       close(2), fcloseall(3), fflush(3), fileno(3), fopen(3), setbuf(3)
51

COLOPHON

53       This  page  is  part of release 5.13 of the Linux man-pages project.  A
54       description of the project, information about reporting bugs,  and  the
55       latest     version     of     this    page,    can    be    found    at
56       https://www.kernel.org/doc/man-pages/.
57
58
59
60GNU                               2021-03-22                         FCLOSE(3)
Impressum