add .Mt to man pages in usr.bin/
[dragonfly.git] / usr.bin / lockf / lockf.1
1 .\"
2 .\" Copyright (C) 1998 John D. Polstra.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
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.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY JOHN D. POLSTRA 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 JOHN D. POLSTRA 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
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD: src/usr.bin/lockf/lockf.1,v 1.7.2.4 2002/06/21 15:27:51 charnier Exp $
26 .\"
27 .Dd July 7, 1998
28 .Dt LOCKF 1
29 .Os
30 .Sh NAME
31 .Nm lockf
32 .Nd execute a command while holding a file lock
33 .Sh SYNOPSIS
34 .Nm
35 .Op Fl ks
36 .Op Fl t Ar seconds
37 .Ar file
38 .Ar command
39 .Op Ar arguments
40 .Sh DESCRIPTION
41 The
42 .Nm
43 utility acquires an exclusive lock on a
44 .Ar file ,
45 creating it if necessary.
46 While holding the lock, it executes a
47 .Ar command
48 with optional
49 .Ar arguments .
50 After the
51 .Ar command
52 completes,
53 .Nm
54 releases the lock, and removes the
55 .Ar file
56 unless the
57 .Fl k
58 option is specified.
59 .Bx Ns -style
60 locking is used, as described in
61 .Xr flock 2 ;
62 the mere existence of the
63 .Ar file
64 is not considered to constitute a lock.
65 .Pp
66 The following options are supported:
67 .Bl -tag -width Fl
68 .It Fl k
69 Causes the lock file to be kept (not removed) after the command
70 completes.
71 .It Fl s
72 Causes
73 .Nm
74 to operate silently.
75 Failure to acquire the lock is indicated only in the exit status.
76 .It Fl t Ar seconds
77 Specifies a timeout for waiting for the lock.  By default,
78 .Nm
79 waits indefinitely to acquire the lock.
80 If a timeout is specified with this option,
81 .Nm
82 will wait at most the given number of
83 .Ar seconds
84 before giving up.  A timeout of 0 may be given, in which case
85 .Nm
86 will fail unless it can acquire the lock immediately.
87 .El
88 .Pp
89 In no event will
90 .Nm
91 break a lock that is held by another process.
92 .Sh DIAGNOSTICS
93 If
94 .Nm
95 successfully acquires the lock, it returns the exit status produced by
96 .Ar command .
97 Otherwise, it returns one of the exit codes defined in
98 .Xr sysexits 3 ,
99 as follows:
100 .Bl -tag -width F_CANTCREATX
101 .It Dv EX_TEMPFAIL
102 The specified lock file was already locked by another process.
103 .It Dv EX_CANTCREAT
104 The
105 .Nm
106 utility
107 was unable to create the lock file, e.g., because of insufficient access
108 privileges.
109 .It Dv EX_USAGE
110 There was an error on the
111 .Nm
112 command line.
113 .It Dv EX_OSERR
114 A system call (e.g., fork) failed unexpectedly.
115 .El
116 .Sh SEE ALSO
117 .Xr flock 2 ,
118 .Xr sysexits 3
119 .Sh HISTORY
120 A
121 .Nm
122 utility first appeared in
123 .Fx 2.2 .
124 .Sh AUTHORS
125 .An John Polstra Aq Mt jdp@polstra.com