NAME
flockfile, ftrylockfile, funlockfile - lock FILE for stdio
SYNOPSIS
#include <stdio.h> void flockfile(FILE *filehandle); int ftrylockfile(FILE *filehandle); void funlockfile(FILE *filehandle); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): All functions shown above: _POSIX_C_SOURCE || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
DESCRIPTION
The stdio functions are thread-safe. This is achieved by assigning to each FILE object a lockcount and (if the lockcount is nonzero) an owning thread. For each library call, these functions wait until the FILE object is no longer locked by a different thread, then lock it, do the requested I/O, and unlock the object again. (Note: this locking has nothing to do with the file locking done by functions like flock(2) and lockf(3).) All this is invisible to the C-programmer, but there may be two reasons to wish for more detailed control. On the one hand, maybe a series of I/O actions by one thread belongs together, and should not be interrupted by the I/O of some other thread. On the other hand, maybe the locking overhead should be avoided for greater efficiency. To this end, a thread can explicitly lock the FILE object, then do its series of I/O actions, then unlock. This prevents other threads from coming in between. If the reason for doing this was to achieve greater efficiency, one does the I/O with the nonlocking versions of the stdio functions: with getc_unlocked(3) and putc_unlocked(3) instead of getc(3) and putc(3). The flockfile() function waits for *filehandle to be no longer locked by a different thread, then makes the current thread owner of *filehandle, and increments the lockcount. The funlockfile() function decrements the lock count. The ftrylockfile() function is a nonblocking version of flockfile(). It does nothing in case some other thread owns *filehandle, and it obtains ownership and increments the lockcount otherwise.
RETURN VALUE
The ftrylockfile() function returns zero for success (the lock was obtained), and nonzero for failure.
ERRORS
None.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). Interface Attribute Value flockfile(), ftrylockfile(), Thread safety MT-Safe funlockfile()
CONFORMING TO
POSIX.1-2001, POSIX.1-2008.
AVAILABILITY
These functions are available when _POSIX_THREAD_SAFE_FUNCTIONS is defined.
SEE ALSO
unlocked_stdio(3)
COLOPHON
This page is part of release 4.09 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. 2016-03-15 FLOCKFILE(3)
More Linux Commands
manpages/gnutls_x509_crq_get_key_purpose_oid.3.html
gnutls_x509_crq_get_key_purpose_oid(3) - API function.......
gnutls_x509_crq_get_key_purpose_oid.3 - This function will extract the key purpose OIDs of the Certificate specified by the given index. These are stored in the
manpages/mkfontscale.1.html
mkfontscale(1) - create an index of scalable font files for
For each directory argument, mkfontscale reads all of the scalable font files in the directory. For every font file found, an X11 font name (XLFD) is generated,
manpages/setrpcent.3.html
setrpcent(3) - get RPC entry (Library - Linux man page).....
setrpcent.3 - The getrpcent(), getrpcbyname(), and getrpcbynumber() functions each return a pointer to an object with the following structure containing the bro
manpages/cargl.3.html
cargl(3) - calculate the complex argument - Linux man page
A complex number can be described by two real coordinates. One may use rectangular coordinates and gets z = x + I * y where x = creal(z) and y = cimag(z). Or on
manpages/XtInitialize.3.html
XtInitialize(3) - initialize (Library - Linux man page).....
XtInitialize calls XtToolkitInitialize followed by XtOpenDisplay with display_string NULL and application_name NULL, and finally calls XtAppCreateShell with app
manpages/gpg.1.html
gpg(1) - OpenPGP encryption and signing tool (Man Page).....
gpg2 is the OpenPGP part of the GNU Privacy Guard (GnuPG). It is a tool to provide digital encryption and signing services using the OpenPGP standard. gpg2 feat
manpages/pano_modify.1.html
pano_modify(1) - Change output parameters of project file...
pano_modify modifies a single Hugin .pto project. OPTIONS -o, --output=file.pto Output Hugin PTO file. Default: <filename>_mod.pto -p, --projection=NUMBER Sets
manpages/XtVaCreatePopupShell.3.html
XtVaCreatePopupShell(3) - create a popup shell (Man Page)...
The XtCreatePopupShell function ensures that the specified class is a subclass of Shell and, rather than using insert_child to attach the widget to the parents
manpages/gnutls_certificate_set_dh_params.3.html
gnutls_certificate_set_dh_params(3) - API function (ManPage)
This function will set the Diffie-Hellman parameters for a certificate server to use. These parameters will be used in Ephemeral Diffie-Hellman cipher suites. N
manpages/_tracechtype.3ncurses.html
_tracechtype(3ncurses) - curses debugging routines (ManPage)
The trace routines are used for debugging the ncurses libraries, as well as applications which use the ncurses libraries. These functions are normally available
manpages/current_item.3menu.html
current_item(3menu) - set and get current_menu_item.........
The function set_current_item sets the current item (the item on which the menu cursor is positioned). current_item returns a pointer to the current item in the
manpages/gnutls_openpgp_privkey_set_preferred_key_id.3.html
gnutls_openpgp_privkey_set_preferred_key_id.3...............
This allows setting a preferred key id for the given certificate. This key will be used by functions that involve key handling. RETURNS On success, 0 is returne
