icon Top 9 categories map      RocketAware > man pages >


Tips: Browse or Search all pages for efficient awareness of more than 6000 of the most popular reusable and open source applications, functions, libraries, and FAQs.

The "RKT couplings" below include links to source code, updates, additional information, advice, FAQs, and overviews.


Search all pages


By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Integer, Floating point, Matrix, Statistics, Boolean, ...

Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


RocketLink!--> Man page versions:

FLOCKFILE(3)              OpenBSD Programmer's Manual             FLOCKFILE(3)

     flockfile, ftrylockfile, funlockfile - application level locking of stdio

     #include <stdio.h>

     flockfile(FILE *file);

     ftrylockfile(FILE *file);

     funlockfile(FILE *file);

     The flockfile(), ftrylockfile(), and funlockfile() functions provide for
     explicit application-level locking of stdio FILE * objects. These func-
     tions 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 * object.

     The ftrylockfile() function is used by a thread to acquire ownership of a
     FILE * object if the object is available; ftrylockfile() is a non-block-
     ing version of flockfile().

     The funlockfile() function is used to relinquish the ownership granted to
     the thread.  The behaviour is undefined if a thread other than the cur-
     rent owner calls the funlockfile() function.

     Logically, there is a lock count associated with each FILE * object. This
     count is implicitly intialized to zero when the FILE * object is created.
     The FILE * object is unlocked when the count is zero.  When the count is
     positive, a single thread owns the FILE * object. When the flockfile()
     function is called, if the count is zero or if the count is positive and
     the caller owns the FILE * object, the count is incremented.  Otherwise,
     the calling thread is suspended, waiting for the count to return to zero.
     Each call to funlockfile() decrements the count. This allows matching
     calls to flockfile() (or successful calls to ftrylockfile()) and
     funlockfile() to be nested.

     Library functions that reference FILE * behave as if they use flockfile()
     and funlockfile() internally to obtain ownership of these FILE * objects.

     None for flockfile() and funlockfile().  The function ftrylock() returns
     zero for success and non-zero to indicate that the lock cannot be ac-


     getc_unlocked(3),  getchar_unlocked(3),  pthreads(3),  putc_unlocked(3),

     flockfile(), ftrylockfile() and funlockfile() conform to ISO/IEC 9945-1
     ANSI/IEEE (``POSIX'') Std 1003.1c/D10.

OpenBSD 2.6                     August 20, 1998                              1

Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.

(Corrections, notes, and links courtesy of RocketAware.com)

[Detailed Topics]

[Overview Topics]

RocketLink!--> Man page versions:

Rapid-Links: Search | About | Comments | Submit Path: RocketAware > man pages > flockfile.3/
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments