fclose (3)
Leading comments
Copyright (c) 1990, 1991 The Regents of the University of California. All rights reserved. This code is derived from software contributed to Berkeley by Chris Torek and the American National Standards Committee X3, on Information Processing Systems. %%%LICENSE_START(BSD_4_CLAUSE_UCB) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above c...
NAME
fclose - close a streamSYNOPSIS
#include <stdio.h>int fclose(FILE *stream);
DESCRIPTION
The fclose() function flushes the stream pointed to by stream (writing any buffered output data using fflush(3)) and closes the underlying file descriptor.The behaviour of fclose() is undefined if the stream parameter is an illegal pointer, or is a descriptor already passed to a previous invocation of fclose().
RETURN VALUE
Upon successful completion 0 is returned. Otherwise, EOF is returned and errno is set to indicate the error. In either case any further access (including another call to fclose()) to the stream results in undefined behavior.ERRORS
- EBADF
- The file descriptor underlying stream is not valid.
The fclose() function may also fail and set errno for any of the errors specified for the routines close(2), write(2) or fflush(3).
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).Interface | Attribute | Value |
fclose() | Thread safety | MT-Safe |