Enric Roca wrote:
> Hello,
> 
> I'm new in Perl programming and I think that this is an easy question
> for you:
> 
> I'm using Apache 1.3.26 and Perl 5.5.3 and I don't want to install
> additional modules if I can avoid it.
> I have an script, ex. test.pl that must control if it is already
> executing, and if it is, it must wait for some seconds. I don't want
> to use Proc::ProcessTable or other libraries. I would like to do this
> with the standard Perl 5.5.3.
> 
> So, I need to create a global variable (environment variable, etc)
> and set his value to EXECUTING (1 for instance) when the script
> begins and change his value to FREE (0 for example) when the perl
> script finish. Every time that the script begins must check the value
> of this variable and wait some seconds and try again if the other
> processes have finished. 
> 
> Is there any easy way to do this without installing extra modules ?

Have your script acquire a lock on a file when it starts. If a second
instance is started, it will block while trying to acquire the lock until
the first script releases the lock or exits.

perldoc -f flock

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to