]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
flock: Add new example using shell IO redirection
authorJookia <contact@jookia.org>
Thu, 23 Jan 2020 04:55:35 +0000 (04:55 +0000)
committerGitHub <noreply@github.com>
Thu, 23 Jan 2020 04:55:35 +0000 (04:55 +0000)
sys-utils/flock.1

index 0a4da9d468edc8d8657b69a3e89462b7256301f9..6762ecb4ce8982fc938ecd0c6f941624934bb6a2 100644 (file)
@@ -166,6 +166,14 @@ run.  If the env var $FLOCKER is not set to the shell script that is being run,
 then execute flock and grab an exclusive non-blocking lock (using the script
 itself as the lock file) before re-execing itself with the right arguments.  It
 also sets the FLOCKER env var to the right value so it doesn't run again.
+.TP
+.TQ
+exec 4<>/var/lock/mylockfile
+.TQ
+flock -n 4
+This form is convenient for locking a file without spawning a subprocess.
+The shell opens the lock file for reading and writing as file descriptor 4,
+then flock is used to lock the descriptor.
 .SH "EXIT STATUS"
 The command uses
 .B sysexits.h