This is the mail archive of the 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]

fcntl and flockfile man pages


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 ?).


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