Unix/Linux Go Back    

NetBSD 6.1.5 - man page for ftrylockfile (netbsd section 3)

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:   man
Select Man Page Set:       apropos Keyword Search (sections above)

FLOCKFILE(3)			   BSD Library Functions Manual 		     FLOCKFILE(3)

     flockfile, ftrylockfile, funlockfile -- stdio stream locking functions

     Standard C Library (libc, -lc)

     #include <stdio.h>

     flockfile(FILE *file);

     ftrylockfile(FILE *file);

     funlockfile(FILE *file);

     The flockfile(), ftrylockfile(), and funlockfile() functions provide applications with
     explicit control of locking of stdio stream objects.  They can be used by a thread to exe-
     cute a sequence of I/O operations as a unit, without interference from another thread.

     Locks on stdio streams are recursive, and a lock count is maintained.  stdio streams are
     created unlocked, with a lock count of zero.  After successful acquisition of the lock, its
     count is incremented to one, indicating locked state of the stdio stream.	Each subsequent
     relock operation performed by the owner thread increments the lock count by one, and each
     subsequent unlock operation performed by the owner thread decrements the lock count by one,
     allowing matching lock and unlock operations to be nested.  After its lock count is decre-
     mented to zero, the stdio stream returns to unlocked state, and ownership of the stdio
     stream is relinquished.

     The flockfile() function acquires the ownership of file for the calling thread.  If file is
     already owned by another thread, the calling thread is suspended until the acquisition is
     possible (i.e., file is relinquished again and the calling thread is scheduled to acquire

     The ftrylockfile() function acquires the ownership of file for the calling thread only if
     file is available.

     The funlockfile() function relinquishes the ownership of file previously granted to the
     calling thread.  Only the current owner of file may funlockfile() it.

     If successful, the ftrylockfile() function returns 0.  Otherwise, it returns non-zero to
     indicate that the lock cannot be acquired.

     flock(2), getc_unlocked(3), getchar_unlocked(3), lockf(3), putc_unlocked(3),

     The flockfile(), ftrylockfile() and funlockfile() functions conform to IEEE Std 1003.1-2001

     The flockfile() function first appeared in FreeBSD 2.0.

     The design of these interfaces does not allow for addressing the problem of priority inver-

BSD					 October 15, 2011				      BSD
Unix & Linux Commands & Man Pages : ©2000 - 2018 Unix and Linux Forums

All times are GMT -4. The time now is 06:11 AM.