#include <unistd.h>

int fsync(int fildes);


Declared, not implemented


IEEE Std 1003.1-2017


The fsync() function shall request that all data for the open file descriptor named by fildes is to be transferred to the storage device associated with the file described by fildes. The nature of the transfer is implementation-defined.

The fsync() function shall not return until the system has completed that action or until an error is detected.

If _POSIX_SYNCHRONIZED_IO is defined, the fsync() function shall force all currently queued I/O operations associated with the file indicated by file descriptor fildes to the synchronized I/O completion state. All I/O operations shall be completed as defined for synchronized I/O file integrity completion.

Return value#

Upon successful completion, fsync() shall return 0. Otherwise, -1 shall be returned and errno set to indicate the error. If the fsync() function fails, outstanding I/O operations are not guaranteed to have been completed.


The fsync() function shall fail if:

  • EBADF - The fildes argument is not a valid descriptor.

  • EINTR - The fsync() function was interrupted by a signal.

  • EINVAL - The fildes argument does not refer to a file on which this operation is possible.

  • EIO - An I/O error occurred while reading from or writing to the file system.

In the event that any of the queued I/O operations fail, fsync() shall return the error conditions defined for read() and write().



Known bugs#


See Also#

  1. Standard library functions

  2. Table of Contents