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

Re: File locking within zsh?



"Brian K. White" <brian@xxxxxxxxx> writes:

> From: "Tim Writer" <tim@xxxxxxxxxxx>
>
>> [ ... ]
>>
>>    while ! ln file file.lock 2>/dev/null
>>    do
>>        sleep 1
>>    done
>>    # Lock obtained
>>
>>    print foo bar baz >>file
>>    # do a whole lot of other stuff to "file"
>>
>>    rm -f file.lock
>>    # Lock released
>>
>> Wrapping this idiom into lock/unlock functions is left as an exercise
>> for the
>> reader. :-)
>
>
> Is that better or worse, and why, than  umask 222 ; >file ?
>
> http://www.unix.org.ua/orelly/unix/upt/ch45_36.htm

Thanks to both of you (Brian K. White and Tim Writer).  I personally
like the umask version better, because I think I can implement a
variation of it without spawning any extra processes (my goal), given
that umask is an internal zsh command.


-- 
 Lloyd Zusman
 ljz@xxxxxxxxxx
 God bless you.



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