From 07b6256d8ea03805dd8a24c184bf455ee31d6115 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 26 Feb 2010 12:09:20 +0000 Subject: 27756: add OS file locking to calendar add errflag test to loop over fcntl() --- Functions/Calendar/calendar | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Functions/Calendar/calendar') 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 +) -- cgit v1.2.3-70-g09d2