Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jul 2011 13:21:08 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Unga <unga888@yahoo.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: How to sync a file on FreeBSD?
Message-ID:  <20110722132108.da198648.freebsd@edvax.de>
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 Thu, 21 Jul 2011 23:44:00 -0700 (PDT), 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.

Maybe you can use system("/bin/sync"); or sync(); in
your program?

Check "man 8 sync": "force completion of pending disk
writes (flush cache)" as well as "man 2 sync": "The
sync() system call forces a write of dirty (modified)
buffers in the block buffer cache out to disk."

Is this "immediately" enough for your needs?


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



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