*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: fclose | Section: 3 | Source: Digital UNIX | File: fclose.3.gz
fclose(3) Library Functions Manual fclose(3) NAME fclose, fflush, fclose_unlocked, fflush_unlocked - Closes or flushes a stream LIBRARY Standard C Library (libc.so, libc.a) SYNOPSIS #include <stdio.h> int fclose ( FILE *stream); int fclose_unlocked( FILE *stream); int fflush( FILE *stream); int fflush_unlocked( FILE *stream); STANDARDS Interfaces documented on this reference page conform to industry stan- dards as follows: fclose(), fflush(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about in- dustry standards and associated tags. PARAMETERS Specifies the output or update stream. DESCRIPTION The fclose() function writes buffered data to the stream specified by the stream parameter, and then closes the associated file. The func- tion is automatically called for all open files when the exit() func- tion is invoked. Any unwritten buffered data for the stream is deliv- ered to the host environment to be written to the file; any unread buffered data is discarded. The stream is disassociated from the file. If the associated buffer was automatically allocated, it is deallo- cated. Any further use of the stream specified by the stream parameter causes undefined behavior. The fclose() function performs the close() function on the file de- scriptor associated with the stream parameter. If the stream was writable and buffered data was not yet written to the file, it marks the st_ctime and st_mtime fields of the underlying file for update. The fflush() function writes any buffered data for the stream specified by the stream parameter and leaves the stream open. If stream is a null pointer, the fflush() function performs this flushing action on all streams for which the behavior was previously defined. The st_ctime and st_mtime fields of the underlying file are marked for up- date. [Digital] The fclose_unlocked() and fflush_unlocked() functions are functionally identical to the fclose() and fflush() functions, except that fclose_unlocked() and fflush_unlocked() may be safely used only within a scope that is protected by the flockfile() and funlockfile() functions used as a pair. The caller must ensure that the stream is locked before these functions are used. RETURN VALUES Upon successful completion, the fclose(), fflush(), fclose_unlocked(), and fflush_unlocked() functions return a value of 0 (zero). Otherwise, EOF is returned, and errno is set to indicate the error. ERRORS The fclose(), fflush(), fclose_unlocked(), and fflush_unlocked() func- tions set errno to the specified value for following conditions: The O_NONBLOCK flag is set for the file descriptor underlying the stream parameter and the process would be delayed in the write operation. The file descriptor underlying the stream parameter is not valid. An at- tempt was made to write a file that exceeds the process's file size limit or the maximum file size. (See the ulimit(3) reference page). The function was interrupted by a signal that was caught. The TOSTOP tty local mode causes a background process to get a SIGTTOU signal if it attempts to write to the controlling terminal. The SIGTTOU signal, if it is not caught or ignored, will cause the process to block in a stopped state. A process in an orphaned process group is not allowed to become stopped, since there is no unprivileged process to unblock it. This condition only applies to operations on stdio streams associ- ated with ttys. [EIO] is also associated with driver errors. There was no free space remaining on the device containing the file. An attempt was made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal will also be sent to the process. RELATED INFORMATION Functions: close(2), exit(2), fopen(3), setbuf(3) Standards: standards(5) delim off fclose(3)

Navigation Options