This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
fcntl and flockfile man pages
- From: "Jairo19 at interhosting dot us" <jairo19 at interhosting dot us>
- To: libc-alpha at sources dot redhat dot com
- Date: Wed, 24 Oct 2007 11:25:33 -0400
- Subject: fcntl and flockfile man pages
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.
If the following is correct it may be worth adding something similar
to both man pages to aid programmers choose the correct functions to use:
" when using the thread_safe stdio functions, the simpler recommended
locking mechanism is to use flockfile()/ftrylockfile()/funlockfile() for
full file locking,
when using low level functions like read(2) and wrote(2) or when record
level locking is needed, the recommended locking mechanism is to use
fcntl() to request and free the lock."
Does the above make sense ?
Also, I do not see anything that tells me if flockfile() creates
mandatory locks (is it implied ?).
Regards.