Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

flockfile(3s) [hpux man page]

flockfile(3S)															     flockfile(3S)

NAME
flockfile(), ftrylockfile(), funlockfile() - explicit locking of streams within a multithread application SYNOPSIS
DESCRIPTION
The and functions provide for explicit application-level locking of streams. These functions can be used by a thread to delineate a sequence of I/O statements that are to be executed as a unit. The function is used by a thread to acquire ownership of a object. The function is used by a thread to acquire ownership of a object if the object is available; is a non-blocking version of The function is used to relinquish the ownership granted to the thread. The behavior is undefined if a thread other than the current owner calls the function. Logically, there is a count associated with each stream. This count is implicitly initialized to zero when the stream is created. The stream is unlocked when the count is zero. When the count is positive, a single thread owns the stream. When the function is called, if the count is zero or if the count is positive and the caller owns the stream, the count is incremented. Otherwise, the calling thread is suspended, waiting for the count to return to zero. Each call to decrements the count. This allows matching calls to (or successful calls to and to be nested. All POSIX.1 and C standard functions that reference objects behave as if they use and internally to obtain ownership of these objects. RETURN VALUE
None for and The function returns zero for success and nonzero to indicate that the lock cannot be acquired. flockfile(3S)

Check Out this Related Man Page

flockfile(3)						     Library Functions Manual						      flockfile(3)

NAME
flockfile, ftrylockfile, funlockfile - stdio locking functions LIBRARY
Standard C Library (libc.a) SYNOPSIS
#include <stdio.h> void flockfile( FILE * file); int ftrylockfile( FILE * file); void funlockfile( FILE * file); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: flockfile, funlockfile: POSIX.1c, XSH5.0 ftrylockfile: XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the stream to be locked. DESCRIPTION
The flockfile(), ftrylockfile, and funlockfile functions provide for explicit application-level locking of stdio (FILE*) objects. These functions can be used by a thread to delineate a sequence of I/O statements that are to be executed as a unit. The flockfile() function locks a stdio stream so that a thread can have exclusive use of that stream for multiple I/O operations. Use the flockfile() function for a thread that wishes to ensure that the output of several printf() functions, for example, is not garbled by another thread also trying to use printf(). The ftrylockfile() function is used by a thread to acquire ownership of a stdio (FILE*) object if the object is available. The ftrylock- file() function is a non-blocking version of flockfile(). The funlockfile() function unlocks a stdio stream, causing the thread that had been holding the lock to relinquish exclusive use of the stream. The behavior of the flockfile() and funlockfile() functions is unspecified if the file parameter does not point to a valid FILE structure. The behavior of funlockfile() is also unspecified if a thread other than the current owner calls funlockfile(). Matching flockfile() and funlockfile() calls can be nested. If the stream has been locked recursively, it will remain locked until the last matching funlockfile() is called. RETURN VALUE
None for flockfile() and funlockfile(). The ftrylockfile() function returns zero for success and non-zero to indicate that the lock cannot be acquired. RELATED INFORMATION
Functions: getc_unlocked(3), putc_unlocked(3) delim off flockfile(3)
Man Page

Featured Tech Videos