summaryrefslogtreecommitdiffstats
path: root/sys-utils/flock.1
diff options
context:
space:
mode:
authorJan \"Yenya\" Kasprzak2012-06-05 16:26:58 +0200
committerKarel Zak2012-06-15 11:12:06 +0200
commit827b1ceefdfdb3b4b55affb32f3c315abb7ad3fb (patch)
tree4e9ecb6129ed6d6182d39c40a47a649386977e31 /sys-utils/flock.1
parentmount: (new) allow sloppy for non-root (diff)
downloadkernel-qcow2-util-linux-827b1ceefdfdb3b4b55affb32f3c315abb7ad3fb.tar.gz
kernel-qcow2-util-linux-827b1ceefdfdb3b4b55affb32f3c315abb7ad3fb.tar.xz
kernel-qcow2-util-linux-827b1ceefdfdb3b4b55affb32f3c315abb7ad3fb.zip
flock: user-configurable exit code
When locking the file fails with -n or -w option, caller has no way to distinguish between the exit code 1 of the -c command, and the exit code 1 of flock(1) caused by the conflicting lock. Add a new -E <exitcode> (--conflict-exit-code) option to set the exit code for the case of locking failure to any value.
Diffstat (limited to 'sys-utils/flock.1')
-rw-r--r--sys-utils/flock.119
1 files changed, 16 insertions, 3 deletions
diff --git a/sys-utils/flock.1 b/sys-utils/flock.1
index 5a6f27fbb..b50c619cf 100644
--- a/sys-utils/flock.1
+++ b/sys-utils/flock.1
@@ -71,13 +71,19 @@ cases, for example if the enclosed command group may have forked a background
process which should not be holding the lock.
.TP
\fB\-n\fP, \fB\-\-nb\fP, \fB\-\-nonblock\fP
-Fail (with an exit code of 1) rather than wait if the lock cannot be
+Fail rather than wait if the lock cannot be
immediately acquired.
+See the
+.I \-E
+option for the exit code used.
.TP
\fB\-w\fP, \fB\-\-wait\fP, \fB\-\-timeout\fP \fIseconds\fP
-Fail (with an exit code of 1) if the lock cannot be acquired within
+Fail if the lock cannot be acquired within
.IR seconds .
Decimal fractional values are allowed.
+See the
+.I \-E
+option for the exit code used.
.TP
\fB\-o\fP, \fB\-\-close\fP
Close the file descriptor on which the lock is held before executing
@@ -86,6 +92,11 @@ This is useful if
.B command
spawns a child process which should not be holding the lock.
.TP
+\fB\-E\fP, \fB\-\-conflict\-exit\-code\fP \fInumber\fP
+The exit code used when the \fB\-n\fP option is in use, and the
+conflicting lock exists, or the \fB\-w\fP option is in use,
+and the timeout is reached. The default value is 1.
+.TP
\fB\-c\fP, \fB\-\-command\fP \fIcommand\fP
Pass a single
.IR command ,
@@ -134,7 +145,9 @@ return values for everything else but an options
.I \-n
or
.I \-w
-failures which return 1.
+failures which return either the value given by the
+.I \-E
+option, or 1 by default.
.SH AUTHOR
.UR hpa@zytor.com
H. Peter Anvin