I found a need for a general lockfile in something I'm doing. I
don't have experience setting my own, but at first went with
this:
:0 flags
* conditions
{
DUMMY=`lockfile -l 30 $SPAMSNAG.lock; \
cat $mytmpfile.sa >> $SPAMSNAG && \
rm -f $mytmpfile.sa $SPAMSNAG.lock`
:0 # no lockfile here; .myspam is a directory, not a flat file
.myspam
}
That works fine. But then I read a posting from Philip on Wednesday
and realized (I had forgotten) procmail can run LOCKFILE as an
internal command. So I changed the above. Now I have in the braces:
{
# what's the file to use? Lock it
LOCKFILE = $SPAMSNAG$LOCKEXT
LOCKTIMEOUT = 30
DUMMY=`cat $mytmpfile.sa >> $SPAMSNAG && rm -f $mytmpfile.sa`
# unlock file
LOCKFILE
:0 # no lockfile here; .myspam is a directory, not a flat file
.myspam
}
Okay, but I'm not entirely sure that it works. I run a procmail process
that triggers this in the background, and meanwhile I keep doing dir
listings.
I never see the lockfile. I saw it on my initial command-set. Does
anybody
have an idea or some reassurance that this (canonical, I suppose) way is
better?
I do see in the verbose log this:
procmail: Assigning "LOCKFILE=spamsnag.lock"
procmail: Locking "spamsnag.lock"
(So why can't I see the lockfile in my dir listing?)
Oh, and -- mimicking Philip's style from the post that jogged my
memory about LOCKFILE -- I first had in place of DUMMY in the second
version:
# do whatever to create or alter file contents
#:0 c
# | cat $mytmpfile.sa >> $SPAMSNAG && rm -f $mytmpfile.sa
I think that worked as well, but the verbose logs troubled me,
because they read
procmail: Executing " cat $mytmpfile.sa >> $SPAMSNAG && rm -f
$mytmpfile.sa"
procmail: Error while writing to " cat $mytmpfile.sa >> $SPAMSNAG &&
rm -f $mytmpfile.sa"
procmail: Assigning "LASTFOLDER= cat $mytmpfile.sa >> $SPAMSNAG &&
rm -f $mytmpfile.sa"
That "Error" scares me. I think it's not really an error, but an
indication that the piped commands don't do anything with what's
fed them? Oh, yeah, that might be it. I suppose I need an `i'
flag on that recipe.
Anyway, which syntax is better?
Thanks,
Dallman
--
Dallman Ross
"If you find a path with no obstacles, it probably does not lead to
anywhere."
Thoughts of Rev. Sunnan Kubose, from _Zen in the Markets_
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail