FSYNC(2) BSD FSYNC(2)
NAME
fsync - synchronize a file's in-memory state with that on disk
SYNOPSIS
fsync(fd)
int fd;
DESCRIPTION
fsync causes all modified data and attributes of fd to be moved to a
permanent storage device. This normally causes all in-memory modified
copies of buffers for the associated file to be written to a disk.
fsync should be used by programs that require a file to be in a known
state; for example, in building a simple transaction facility.
ERRORS
The fsync fails if any of the following are true:
[EBADF] fd is not a valid descriptor.
[EINVAL] fd refers to a socket, not to a file.
[EIO] An I/O error occurred while reading from or writing to the
file system.
SEE ALSO
sync(2), sync(8), update(8)
DIAGNOSTICS
A successful call returns 0. A failed call returns -1 and sets errno to
indicate the error.