summaryrefslogtreecommitdiffstats
path: root/Functions/Calendar/calendar
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-02-26 12:09:20 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-02-26 12:09:20 +0000
commit07b6256d8ea03805dd8a24c184bf455ee31d6115 (patch)
tree98e16977e063db6d46c7b13e4b82c3cef3978dd9 /Functions/Calendar/calendar
parentusers/14891: say that condition arguments don't do globbing (diff)
downloadzsh-07b6256d8ea03805dd8a24c184bf455ee31d6115.tar
zsh-07b6256d8ea03805dd8a24c184bf455ee31d6115.tar.gz
zsh-07b6256d8ea03805dd8a24c184bf455ee31d6115.tar.bz2
zsh-07b6256d8ea03805dd8a24c184bf455ee31d6115.tar.lz
zsh-07b6256d8ea03805dd8a24c184bf455ee31d6115.tar.xz
zsh-07b6256d8ea03805dd8a24c184bf455ee31d6115.tar.zst
zsh-07b6256d8ea03805dd8a24c184bf455ee31d6115.zip
27756: add OS file locking to calendar
add errflag test to loop over fcntl()
Diffstat (limited to 'Functions/Calendar/calendar')
-rw-r--r--Functions/Calendar/calendar13
1 files changed, 11 insertions, 2 deletions
diff --git a/Functions/Calendar/calendar b/Functions/Calendar/calendar
index f6316eb18..b87a14628 100644
--- a/Functions/Calendar/calendar
+++ b/Functions/Calendar/calendar
@@ -253,13 +253,21 @@ if (( verbose )); then
fi
fi
+# start of subshell for OS file locking
+(
# start of block for following always to clear up lockfiles.
+# Not needed but harmless if OS file locking is used.
{
if [[ -n $donefile ]]; then
# Attempt to lock both $donefile and $calendar.
# Don't lock $newfile; we've tried our best to make
# the name unique.
- calendar_lockfiles $calendar $donefile || return 1
+ if zmodload -F zsh/system b:zsystem && zsystem supports flock; then
+ zsystem flock $calendar
+ zsystem flock $donefile
+ else
+ calendar_lockfiles $calendar $donefile || exit 1
+ fi
fi
calendar_read $calendar
@@ -414,4 +422,5 @@ Old calendar left in $calendar.old." >&2
(( ${#lockfiles} )) && rm -f $lockfiles
}
-return $rstat
+exit $rstat
+)