procmail
[Top] [All Lists]

Procmail/Perl and locking

2004-07-14 05:01:39
Hi

I made a Perl script which converts some filecontent into several
emails. At the end of the script, I have a bunch of emails stored in a
variable (formatted like a standard mailbox). So far, everything works
perfect.

All left to do is to append the content of the variable to the mailbox.
No problem at all, but for the sake of security, I want to lock the
mailbox before writing to it (in case Procmail wants to add a mail too).

Now I thought about doing something like this:

use Fcntl qw(:DEFAULT :flock);
open(MBOX, ">>/path/to/mbox") or die $!;
flock(MBOX, LOCK_EX) || die "flock failed on mbox $!";
print MBOX $emails;
close(MBOX) or warn "close failed for mbox $!";

Afaik my Procmail uses dotlocking (Locking strategies: dotlocking,
lockf). Now I wonder if the above Perl code will be safe, or if there
still is the chance that I run into Procmail/Perl file access problems.
If so, has anybody a better idea (or link)?

Greetings
Sven





____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>