Re: Unable to lock a file to stop sendmail writing to it
- From: Ben Morrow <benmorrow@xxxxxxxxxxxxx>
- Date: Thu, 20 Jul 2006 10:35:50 +0100
Quoth "GarfGarf" <garfield_99999@xxxxxxxxx>:
Gunnar Hjalmarsson wrote:
GarfGarf wrote:
I am trying to write a script that reads a mailbox that sendmail
updates, but I want to be able to lock the file, read the file, empty
the file and unlock the file again.
The problem I have is that locking doesn't seem to work.
I think your problem is merely a misconception with respect to the
meaning of flock(). As stated in
perldoc -f flock
the nature of an flock() lock is advisory.
sendmail writes into the file while i'm writing and that
causes all sorts of problems.
That's probably because sendmail doesn't use flock on the mailboxes.
Ok, thanks for the replies.
It seems flock is not the way to go..
So, how can I lock the file to stop sendmail spatting it?
You need to find out how sendmail *does* lock the files, then do the
same. It might use flock locking, fcntl locking or create a lockfile.
Then you do the same.
FWIW, if you use maildir mail folders you don't need locking...
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
Heraclitus
benmorrow@xxxxxxxxxxxxx
.
- References:
- Unable to lock a file to stop sendmail writing to it
- From: GarfGarf
- Re: Unable to lock a file to stop sendmail writing to it
- From: Gunnar Hjalmarsson
- Re: Unable to lock a file to stop sendmail writing to it
- From: GarfGarf
- Unable to lock a file to stop sendmail writing to it
- Prev by Date: Re: How to find out if a certain value is in a list?
- Next by Date: Question on comparing to variables containing integers
- Previous by thread: Re: Unable to lock a file to stop sendmail writing to it
- Next by thread: How to find out if a certain value is in a list?
- Index(es):