Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jul 2011 13:37:15 +0200
From:      Pieter de Goeje <pieter@degoeje.nl>
To:        freebsd-questions@freebsd.org
Cc:        Unga <unga888@yahoo.com>
Subject:   Re: How to sync a file on FreeBSD?
Message-ID:  <201107221337.15804.pieter@degoeje.nl>
In-Reply-To: <1311317040.38368.YahooMailClassic@web160115.mail.bf1.yahoo.com>
References:  <1311317040.38368.YahooMailClassic@web160115.mail.bf1.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, July 22, 2011 08:44:00 AM Unga wrote:
> How to sync a file on FreeBSD (esp. on 8.1) to disk?
> 
> I used fsync(2), but does not immediately flush to disk.
> 
> I want my writing to a file (a log file) immediately available to other
> users to read.

A file doesn't need to be "synced" to disk for other users to read the latest 
data. The application just needs to call write(2) and the data is available. 
It will be written to and read from the operating system's file cache. If 
you're using stdio you can force a write(2) by calling fflush(3).

- Pieter



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107221337.15804.pieter>