[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

flockfile()

Acquire ownership of a file

Synopsis:

#include <stdio.h>

void flockfile( FILE* file );

Arguments:

file
A pointer to the FILE object for the file you want to lock.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The flockfile() function provides for explicit application-level locking of stdio (FILE) objects. This function 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 is used by a thread to acquire ownership of a FILE.

The implementation acts as if there is a lock count associated with each FILE. This count is implicitly initialized to zero when the FILE is created. The FILE object is unlocked when the count is zero. When the count is positive, a single thread owns the FILE. When the flockfile() function is called, if the count is zero or if the count is positive and the caller owns the FILE, the count is incremented. Otherwise, the calling thread is suspended, waiting for the count to return to zero.

Classification:

POSIX 1003.1 TSF

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

getc_unlocked(), getchar_unlocked(), putc_unlocked(), putchar_unlocked()


[Previous] [Contents] [Index] [Next]