aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/lockf
diff options
context:
space:
mode:
authorFernando ApesteguĂ­a <fernape@FreeBSD.org>2020-06-18 08:31:04 +0000
committerFernando ApesteguĂ­a <fernape@FreeBSD.org>2020-06-18 08:31:04 +0000
commit15597d5df201f53ca4c39d82984f2b307543095d (patch)
treefe412939ab65f1389e707bbf701d0b5d62b355a7 /usr.bin/lockf
parent43ad0e153d614689d77a6a4b341f2b163e213b4d (diff)
downloadsrc-15597d5df201f53ca4c39d82984f2b307543095d.tar.gz
src-15597d5df201f53ca4c39d82984f2b307543095d.zip
lockf(1): Add EXAMPLES section
* Add pretty small EXAMPLES section * While here, fix a warning in line 98 (new sentence in new line) Approved by: bcr@ Differential Revision: https://reviews.freebsd.org/D25205
Notes
Notes: svn path=/head/; revision=362299
Diffstat (limited to 'usr.bin/lockf')
-rw-r--r--usr.bin/lockf/lockf.124
1 files changed, 22 insertions, 2 deletions
diff --git a/usr.bin/lockf/lockf.1 b/usr.bin/lockf/lockf.1
index e6204a1e2cbd..7f64de7b4441 100644
--- a/usr.bin/lockf/lockf.1
+++ b/usr.bin/lockf/lockf.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 7, 1998
+.Dd June 18, 2020
.Dt LOCKF 1
.Os
.Sh NAME
@@ -95,7 +95,8 @@ Causes
.Nm
to fail if the specified lock
.Ar file
-does not exist. If
+does not exist.
+If
.Fl n
is not specified,
.Nm
@@ -160,6 +161,25 @@ The
did not exit normally,
but may have been signaled or stopped.
.El
+.Sh EXAMPLES
+The first job takes a lock and sleeps for 5 seconds in the background.
+The second job tries to get the lock and timeouts after 1 second (PID numbers
+will differ):
+.Bd -literal -offset indent
+$ lockf mylock sleep 5 & lockf -t 1 mylock echo "Success"
+[1] 94410
+lockf: mylock: already locked
+.Ed
+.Pp
+The first job takes a lock and sleeps for 1 second in the background.
+The second job waits up to 5 seconds to take the lock and echoes the message on
+success (PID numbers will differ):
+.Bd -literal -offset indent
+$ lockf mylock sleep 1 & lockf -t 5 mylock echo "Success"
+[1] 19995
+Success
+[1]+ Done lockf mylock sleep 1
+.Ed
.Sh SEE ALSO
.Xr flock 2 ,
.Xr lockf 3 ,