FSYNC(2)
NAME
fsync − synchronize a file’s in-core state with that on disk
USAGE
fsync(fd) int fd;
DESCRIPTION
Fsync causes all modified data and attributes of the object referenced by fd to be moved to a permanent (typically disk) storage device. This normally force-writes all modified copies of buffers for the associated file.
Fsync should be used by programs that require a file to be in a known state; for example in building a simple transaction facility.
RETURN VALUE
A successful call returns zero. A failed call returns -1 and sets errno as indicated below.
ERRORS
The fsync fails if:
[EBADF] Fd is not a valid descriptor.
[EINVAL] Fd refers to a socket, not to a file.