This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fcntl and flockfile man pages


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]