zsh-workers
 help / color / mirror / code / Atom feed
* Patch to zsystem flock documentation
@ 2019-03-21 16:37 Clinton Bunch
  2019-03-22 22:18 ` dana
  0 siblings, 1 reply; 2+ messages in thread
From: Clinton Bunch @ 2019-03-21 16:37 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

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.


[-- Attachment #2: flock_print_doc.patch --]
[-- Type: text/plain, Size: 920 bytes --]

--- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Patch to zsystem flock documentation
  2019-03-21 16:37 Patch to zsystem flock documentation Clinton Bunch
@ 2019-03-22 22:18 ` dana
  0 siblings, 0 replies; 2+ messages in thread
From: dana @ 2019-03-22 22:18 UTC (permalink / raw)
  To: Clinton Bunch; +Cc: zsh-workers

On 21 Mar 2019, at 11:37, Clinton Bunch <cdb_zsh@zentaur.org> wrote:
>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.

I think this makes sense. I applied it with a very minor wording/formatting
adjustment

dana


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-22 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 16:37 Patch to zsystem flock documentation Clinton Bunch
2019-03-22 22:18 ` dana

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).