FSYNC(2)
NAME
fsync − synchronize a file’s in-core state with its state on disk
SYNOPSIS
fsync(fildes)
int fildes;
HP−UX COMPATABILITY
Level: Basic Calls: HP-UX/RUN ONLY
Real Time extensions: HP-UX/STANDARD - Real Time
Origin: UCB and HP
DESCRIPTION
Fsync causes all modified data and attributes of fildes to be moved to a permanent storage device. This normally results in all in-core modified copies of buffers for the associated file to be written to a disk. Fsync applies to ordinary files, and applies to block special devices on systems which permit I/O to block special devices.
Fsync should be used by programs which require a file to be in a known state; for example in building a simple transaction facility.
ERRORS
Fsync will fail if one of the following conditions is true and errno will be set accordingly:
[EBADF] Fildes is not a valid descriptor.
[EINVAL] Fildes refers to a file type to which fsync does not apply.
RETURN VALUE
A 0 value is returned on success. A −1 value indicates an error.
WARNING
If the process has multiple file descriptors open on a file and the file descritpors have asynchronous writes pending, then the process cannot be guaranteed that the buffers associated with these writes will be flushed by the fsync(2). The process must wait until all of the writes have completed before performing an fsync(2) call.
BUGS
The current implementation of this call is expensive for large files.
SEE ALSO
fcntl(2), fcntl(7), open(2), select(2), sync(2), sync(8).
Hewlett-Packard — last mod. May 11, 2021