synchronize a file's in-memory state with that on the physical medium
int fsync(int fildes);
fsync moves all modified data and attributes of fildes
to a storage device.
When fsync returns,
all in-memory modified copies
of buffers associated with fildes
have been written to the physical medium.
fsync is different from
which schedules disk I/O for all files
but returns before the I/O completes.
On success, fsync returns 0.
On failure, fsync returns -1 and sets errno to identify the error.
In the following conditions, fsync fails and sets errno to:
fildes is not a valid file descriptor open for writing.
fildes is on a remote machine and the link on that machine is
no longer active.
A signal was caught during execution of the fsync system call.
An I/O error occurred while reading from or writing to the file system.
should be used by programs that require that a file be
in a known state.
For example, a program that contains
a simple transaction facility might use fsync to ensure that all
changes to a file or files caused by a given transaction were
recorded on a storage medium.
The way the data reach the physical medium
depends on both implementation and hardware.
fsync returns when the device
driver tells it that the write has taken place.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005