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

Re: File locking within zsh?



DervishD <zsh@xxxxxxxxxxxx> writes:

>     Hi Lloyd :)

¡Hola Raúl!


>  * Lloyd Zusman <ljz@xxxxxxxxxx> dixit:
>> 
>> [ ... ]
>> 
>> I know that I can do this with a number of compiled executables, but I'm
>> looking for a zsh-only solution.
>
>     Apart from the 'ln' trick, you can do this in Perl if you don't
> want compiled executables.

Well, the perl interpreter is a compiled executable, and a rather heavy
one, at that.  I'm trying to avoid spawning any extra processes.


> [ ... ]
>
>     If you could ellaborate on the problem you're trying to solve, I
> can try to give a better solution.

I'm writing a zsh shell function that might be invoked within concurrent
terminal sessions.  There's a critical section of code within this shell
function that I want to protect with an exclusive lock.  I only need to
protect this critical section from other invocations of this same shell
function.

I know that there are various file locking executables, and I can also
write my own.  Plus, I know that I can get this functionality via
scripts in perl, ruby, python, etc.  I've just been wondering if there's
a way to do this solely within zsh, without any ancillary executables
being spawned.

Perhaps I can write a loadable zsh module which can supply this
capability.


>     Good luck :)

Muchas gracias. :)


-- 
 Lloyd Zusman
 ljz@xxxxxxxxxx
 God bless you.



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