On 20/11/17 02:56 PM, Nathan Stratton Treadway wrote:
> On Mon, Nov 20, 2017 at 14:42:01 -0500, Jean-Louis Martineau wrote:
> > Each process should take a lock on the holding directory (a pid file),
>
> Okay, makes sense.
>
>
> > + my $pidfn = File::Spec->catfile($dirfn, "pid");
> > + if (open(my $pidh, $pidfn)) {
> > + my $pid = <$pidh>;
> > + if (kill($pid, 0) == 0) {
> > + # pid is alive, skip this directory
> > + next;
> > + }
> > + close($pidh);
>
> Quick question: does the above leave $pidh open in the case that pid is
> alive? (That is, if the code hits the "next" does that miss a needed
> call to close()?)

perl automatically close it when it come out of scope.
The close should before the 'if (kill' line.

I appreciate your reviews

Jean-Louis
>
> Nathan
>
>
> ----------------------------------------------------------------------------
> Nathan Stratton Treadway - [email protected] - Mid-Atlantic region
> Ray Ontko & Co. - Software consulting services - http://www.ontko.com/ 
> <http://www.ontko.com/>
> GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt 
> <http://www.ontko.com/~nathanst/gpg_key.txt> 
> ID: 1023D/ECFB6239
> Key fingerprint = 6AD8 485E 20B9 5C71 231C 0C32 15F3 ADCD ECFB 6239
This message is the property of CARBONITE, INC. and may contain confidential or 
privileged information.
If this message has been delivered to you by mistake, then do not copy or 
deliver this message to anyone.  Instead, destroy it and notify me by reply 
e-mail

Reply via email to