fsync - flush filesystem data for a specific file to disk
Standard C Library (libc, -lc)
#include <unistd.h>
int
fsync(int fd);
The fsync function forces a write of dirty filesystem buffers and other dirty filesystem state associated with the object referred to by fd to be written to disk.
fsync should not return until the writes are complete.
On success, fsync returns 0. On error, -1 is returned, and errno is set according to the error encountered.
The following error codes should be returned under the conditions given. Other error codes may be returned for other cases not mentioned here.
EBADF | fd is not a valid file handle. | |
EIO | A hard I/O error occurred. |