Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Patch to zsystem flock documentation



This is a patch to the yodl documention for the zsh/system module's zsystem flock section to note that use of the builtin print with -u option has the side-effect of releasing the lock made by flock.  It also mentions using a sub-shell redirected to the filename as a workaround.

This should be documented since updating the file is one of the reasons one might use flock.

--- zsh-5.7.1/Doc/Zsh/mod_system.yo.old	2018-12-14 01:50:17.000000000 -0600
+++ zsh-5.7.1/Doc/Zsh/mod_system.yo	2019-03-20 10:55:44.004627151 -0500
@@ -177,8 +177,11 @@
 the file descriptor.  The lock terminates when the shell process that
 created the lock exits; it is therefore often convenient to create file
 locks within subshells, since the lock is automatically released when
-the subshell exits.  Status 0 is returned if the lock succeeds, else
-status 1.
+the subshell exits.  Note that use of the print builtin with -u option will,
+as a side effect, release the lock, as will redirection to the file in the
+shell holding the lock.  To work around this use a subshell, e.g.
+(print "message") >> var(file).  Status 0 is returned if the lock succeeds,
+else status 1.
 
 In the second form the file descriptor given by the arithmetic
 expression var(fd_expr) is closed, releasing a lock.  The file descriptor


Messages sorted by: Reverse Date, Date, Thread, Author