I have multiple processes running cygwin/bash that are accessing the same files in a certain directory.
I want to create a lock or semaphore or gate to serialize access to this directory so that no two (or more processes) can access the directory at any one time. As soon as the first process running bash grabs the lock using perl, the perl program exits, bash creates a file, and bash then needs to call a second perl program to release the lock or event so that only one of the other blocking processes can now grab the lock.

Can someone recommend a way to do this in perl or python? How would I do this? I can think of several ways and they all sound difficult
(1) Create a memory resident Win32 Event. This is tedious because the lock will be released when the perl program exists. I need to keep the lock until bash executes a second perl program. I suppose bash could call perl as a child process which would then grab the Win32 event and wait on a socket or a second win32 event until the parent bash program is ready to release the first win32 Event. This sounds much to complicated (and OS specific). Please tell me there is an easier way!

(2) I could use the resource manager built into SQL Server. I don't know how to do this from perl. Is it possible? I don't like this option because it not only requires SQL Server be installed and running but only works on windows.

(3) Is there a way to do it with the Microsoft Access database? While this has the advantage of not requiring a server be running (like SQL Server), it is not OS neutral (and I don't know how to do it).

(4) Perhaps there is cygwin implementation of Unix style semaphore that I can call from perl? Are there any packages for this? This still has the problems of option #1.

(5) Gollly! I don't like any of the above options! They are all so complicated. Is there something simpler? 

Thanks
siegfried


-- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Reply via email to