Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jul 2011 13:21:08 +0200
From:      Polytropon <>
To:        Unga <>
Subject:   Re: How to sync a file on FreeBSD?
Message-ID:  <>
In-Reply-To: <>
References:  <>

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?

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

Want to link to this message? Use this URL: <>