SPUG: Does -i invocation lock files? was Re: Does tie()...

ced at carios2.ca.boeing.com ced at carios2.ca.boeing.com
Fri Jun 16 16:18:24 CDT 2000


At 09:49 14/06/00 -0700, Tim Maher/CONSULTIX wrote:
>I'm teaching my "Intermediate Perl" class this week, and some questions
>about file-locking have arisen.  I could probably find the answers myself by
>reading some source code, but I'd rather spend my time helping my students
>on their lab assignments instead, so I thought I'd ask if anybody knows
>the answers:
>
>	1) Does the -i invocation option lock the files it processes?
>	(Seems like it should, but if it does, that's not documented!)


The Camel shows the following equivalence:


-i.bak    --->  rename($ARGV, $ARGV . '.bak';
                open(ARGVOUT, ">$ARGV");



So I don't believe there's any C<flock>. I just tried the 
following and the second process has no problem getting an 
exclusive lock: 

process 1:   perl -pi.bak -e 'sleep 60' /tmp/tmp

process 2:   perl -e 'open(F,">/tmp/tmp") or die $!; flock F,2 or die $!'



Rgds,
--
Charles DeRykus

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 For Subscriptions, Email to majordomo at pm.org:  ACTION  spug-list  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address





More information about the spug-list mailing list