fsync()
Synchronize the file state
Synopsis:
#include <unistd.h>
int fsync( int filedes );
Arguments:
- filedes
- The descriptor for the file that you want to synchronize.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The fsync() function forces all queued I/O operations for the file specified by the filedes file descriptor to finish, synchronizing the file's state. The function blocks until this is finished.
Although similar to fdatasync(), fsync() also guarantees the integrity of file information such as access and modification times.
Returns:
0 for success, or -1 if an error occurs (errno is set).
Errors:
- EBADF
- The filedes argument is not a valid descriptor.
- EINTR
- The function was interrupted by a signal.
- EINVAL
- The implementation doesn't support synchronized I/O for the given file.
- EIO
- An I/O error occurred.
- ENOSYS
- The fsync() function isn't supported for the filesystem specified by filedes.
Classification:
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
Page updated:
