fcntl and flockfile man pages
Daniel Jacobowitz
drow@false.org
Wed Oct 24 15:49:00 GMT 2007
On Wed, Oct 24, 2007 at 11:25:33AM -0400, Jairo19@interhosting.us wrote:
> Hola:
>
> I was reading the fcntl man page on my Fedora 7(up to date) installation and
> saw the following comment:
>
> "
> Because of the buffering performed by the stdio(3) library, the use
> of record locking
> with routines in that package should be avoided; use read(2) and write(2)
> instead.
> "
>
> But then looking at the flockfile man page I see it states that stdio
> functions are thread safe, which may imply that record locking gives you
> nothing when used.
No. Record locks are for more than just threads in the same process;
they work between processes. Stdio buffering is within one file.
> Also, I do not see anything that tells me if flockfile() creates mandatory
> locks (is it implied ?).
(Note: this locking has nothing to do with the file locking
done by functions like flock(2) and lockf(3).)
flockfile is locking the FILE object, not the underlying file.
--
Daniel Jacobowitz
CodeSourcery
More information about the Libc-alpha
mailing list