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
32       attributes(7).
33
34       ┌──────────┬───────────────┬─────────┐
35Interface Attribute     Value   
36       ├──────────┼───────────────┼─────────┤
37fclose()  │ Thread safety │ MT-Safe │
38       └──────────┴───────────────┴─────────┘

CONFORMING TO

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

NOTES

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

SEE ALSO

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

COLOPHON

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