This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: fcntl and flockfile man pages
- From: Daniel Jacobowitz <drow at false dot org>
- To: "Jairo19 at interhosting dot us" <jairo19 at interhosting dot us>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Wed, 24 Oct 2007 11:49:10 -0400
- Subject: Re: fcntl and flockfile man pages
- References: <471F63ED.9030504@interhosting.us>
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