1 .\" Copyright (c) 2003 Tim J. Robbins
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $FreeBSD: src/lib/libc/stdio/flockfile.3,v 1.3 2003/01/13 01:29:14 tjr Exp $
34 .Nd "stdio locking functions"
40 .Fn flockfile "FILE *stream"
42 .Fn ftrylockfile "FILE *stream"
44 .Fn funlockfile "FILE *stream"
46 These functions provide explicit application-level locking of stdio streams.
47 They can be used to avoid output from multiple threads being interspersed,
48 input being dispersed among multiple readers, and to avoid the overhead
49 of locking the stream for each operation.
53 function acquires an exclusive lock on the specified stream.
54 If another thread has already locked the stream,
56 will block until the lock is released.
60 function is a non-blocking version of
62 if the lock cannot be acquired immediately,
64 returns non-zero instead of blocking.
68 function releases the lock on a stream acquired by an earlier call to
73 These functions behave as if there is a lock count associated
77 is called on the stream, the count is incremented,
80 is called on the stream, the count is decremented.
81 The lock is only actually released when the count reaches zero.
87 functions return no value.
92 returns zero if the stream was successfully locked,