Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: archiving mail



shimpei@example.com (lists.tlug):
>of things could happen between individual calls. If mail gets delivered
>between the move and new creation, the mail could get truncated; if it

Yes, I spotted that bug this morning.

>gets delivered between creation and flock, it could get overwritten by
>whatever the script does afterwards.

You can only lock a filehandle, and you only have a filehandle once
you've opened a file. Perl doesn't have atomic open-and-flock, as far
as I'm aware. The way to fix it would be to use:
 unless (open ORIG, "+>".$file) {
which won't clobber, and writing will be safe since we only write when
we've got a lock.

I still have a lot to learn about Unix file safety, even after a huge
amount of help from tchrist.

-- 
Disillusion? I can make it for you at home!... Besides, why else did you  
come to the City of Expiring Dreams (apologies to Matthew Arnold)?  
 -- Katherine Kaye, on Oxford.
-----------------------------------------------------------------------
Next Technical Meeting: July 8 (Sat)  13:30  Place: LinuxProbe Hall
Next Nomikai meeting: August 18 (Fri) 19:00  Place: TBD
-----------------------------------------------------------------------
more info: http://www.tlug.gr.jp        Sponsor: Global Online Japan


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links