Everything2
Near Matches
Ignore Exact
Full Text
Everything2

fsync

created by premchai21

(thing) by premchai21 (3.1 mon) (print)   ?   (I like it!) Tue Mar 26 2002 at 2:56:10

fsync is a POSIX 1003.1b-1993 standard function which flushes the write buffers associated with an open file descriptor (filehandle). This node describes primarily the fsync found in the GNU C library, glibc, but most of the information may be applicable to other C libraries as well.

fsync's prototype (found in unistd.h) is:

int fsync(int fildes)

where fildes is the file descriptor whose write buffers are to be flushed. fsync does not return until all data associated with the file is written to the appropriate device; when it does, it returns 0 on success, and returns -1 on error, as well as setting errno appropriately:

  1. EBADF - fildes is not a valid file descriptor.
  2. EINVAL - this function is unimplemented by the system.

Note that this function is a cancellation point for multi-threaded programs; protect calls to fsync with cancellation handlers if necessary.

When it is not necessary to flush metadata associated with the file descriptor in question (for instance if the file is of a fixed size), it is possible to use fdatasync instead of fsync, which may be faster; fdatasync will be emulated by a call to fsync if necessary. See also the function sync, which does the same thing except flushing write buffers for the whole system, rather than just one descriptor.

(Most information paraphrased from the GNU C Library Reference Manual, which is under the GNU Free Documentation License.)


printable version
chaos

sync Unimplemented Core Routine Floating point addition POSIX
data EBADF thread standard
Unix C Library buffer overflow device
Emulate associated size For instance
GNU Free Documentation License call metadata protect
System multi-threaded invalid valid
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Nodes to live by:
Kabbalah FAQ
Names of the moons
The Second Coming of Christ already happened
The bride of Vankenstrein - conception
How did I miss the recruiter?
Apocrypha
For the Birds
Yard of Ale
Counting 1 bits
deliciously oily
Everything is a Family
Mad Magazine
market fascism
New Writeups
Clarke
Multiculturalism(idea)
aneurin
Earl of Landaff(person)
Heitah
Pseudocide(idea)
XWiz
Google Knol(lede)
Mythi
July 24, 2008(personal)
locke baron
The fall of Earth(fiction)
BookReader
Fear the Cold(dream)
Pavlovna
Kathleen MacInnes(person)
stainedglass
1(fiction)
kalen
Three "T"s(idea)
octillion369
Undead(idea)
archiewood
Ico(fiction)
Heisenberg
Why I love Everything2(log)
octillion369
Death Knight(person)
XWiz
Are you hoping for a miracle?(review)
Everything 2 is brought to you by the letter C and The Everything Development Company