Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
funlockfile(3) OSS Library Calls Reference Manual
NAME
funlockfile - Allows a thread to relinquish ownership of a stream
LIBRARY
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <stdio.h>
void funlockfile(
FILE ∗∗stream);
PARAMETERS
stream Points to the file structure of an open file.
DESCRIPTION
The funlockfile( ) function is used to relinquish the ownership of a stream granted to a thread.
The behavior is undefined if a thread other than the current owner calls the funlockfile( ) func-
tion.
The funlockfile( ) function is used with the flockfile( ) and ftrylockfile( ) functions to provide for
explicit application-level locking of streams. These functions can be used by a thread to del-
ineate 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 stream.
The ftrylockfile( ) function is used by a thread to acquire ownership of a stream if the stream is
available; ftrylockfile( ) is a non-blocking version of flockfile( ).
Logically, there is a count associated with each stream. This count is implicitly initialized to 0
(zero) when the stream is created. The stream is unlocked when the count is 0 (zero). When the
count is positive, a single thread owns the stream. When the flockfile( ) function is called, if the
count is 0 (zero) or if the count is positive and the caller owns the stream, the count is incre-
mented. Otherwise, the calling thread is suspended while waiting for the count to return to 0
(zero). Each call to funlockfile( ) decrements the count. This behavior allows matching calls to
flockfile( ) (or successful calls to ftrylockfile( )) and funlockfile( ) to be nested.
All POSIX.1 and C standard functions that reference streams behave as if they use flockfile( ) and
funlockfile( ) internally to obtain ownership of streams.
RETURN VALUES
None.
RELATED INFORMATION
Functions: flockfile(3), ftrylockfile(3), getc_unlocked(3), getchar_unlocked(3),
putc_unlocked(3), putchar_unlocked(3).
STANDARDS CONFORMANCE
Interfaces documented on this reference page conform to the following industry standards:
• IEEE Std 1003.1-2004, POSIX System Application Program Interface
2−208 Hewlett-Packard Company 527187-017