Instead of calling the sync system calls, you may
open() your file with the O_SYNC flag, which will automatically flush changes. This is the same as calling fsync() after every call to write()!
Name: |
System call or function: System call | Links: Online Manual | Course Packet |
What it does: closes a file that was open with . It unmaps the open and disassociates the file from the program. The kernel is free to reuse this integer for other files that will be opened. Closing a file doesn't affect when the file is flushed to disk, but it may result in an unlinked file being finally physically erased from the disk. The most common error value is EIO, most likely indicating a low-level I/O error, but the file always gets closed. |
||
What libraries you must include: |
||
Syntax: |
||
Description of arguments: : file descriptor of an open file |
||
What type it returns: |
On success: |
|
On failure: |
||
If failure, does it set ? Yes |
||
Quick example: |
||
| Other variations: N/A | ||
These notes by Miriam Briskman are licensed under CC BY-NC 4.0 and based on sources.