procmail
[Top] [All Lists]

Re: lockfiles on braces

1997-07-07 14:12:00
Martin Ramsch told us,

| I tried to add a line to the logfile if and only if there was a
| duplicate.  What I do now is:
| 
|   :0 cWh: msgid.lock
|   | formail -D 32768 $PMDIR/data.msgid.cache
|   
|     :0 a
|     {
|       LOG="* rc.killfile: duplicate recognised and deleted.$NL"
|       :0
|       /dev/null
|     }

and then he asked,

| But I wonder, why doesn't procmail accept the following variation,
| too?
| 
|   :1 Wh: msgid.lock
|   ? formail -D 8192 $PMDIR/data.msgid.cache
|   {
|     LOG="* rc.killfile: duplicate recognised and deleted.$NL"
|     :0
|     /dev/null
|   }
| 
| This was my first try and seems to be much more straight forward, but
| procmail choked on the lockfile and ignored it.  I wonder why?

You can't lock the action of a left brace.  If you are also launching a
clone, you can lock the clone (the parent procmail will know to remove
the lockfile when the clone terminates), but you can't lock a left brace
that doesn't launch a clone.  [Perhaps the reason is that procmail will
not really know when to unlock it?]

Moreover, it won't do what you want.  A local lockfile is locked during
the *action* of the recipe, and only if (and thus after) the conditions
have passed.  You need the lockfile during the condition if you phrase
it the second way.

Also, `h' and `W' are flags that affect the action, not the condition.
Neither of them makes sense when the action is a left brace.  You don't
need `W' for a condition, because procmail has to wait until the condition
has been evaluated anyway; and you don't need `H' here because, in the
absence of `B', `H' is implicit.

Now, this should work, but note how you have to use a regional lockfile to
pull it off, not a local one:

   LOCKFILE=msgid.lock

   :1 # Martin seems fond of the old syntax.
   ? formail -D 8192 $PMDIR/data.msgid.cache
   {
     # You could unset LOCKFILE here or just let procmail remove the lockfile
     # when it exits.

     # I'll leave Martin's European spelling unchanged.
     LOG="* rc.killfile: duplicate recognised and deleted.$NL"

     :0h
     /dev/null
   }
   LOCKFILE

<Prev in Thread] Current Thread [Next in Thread>
  • Re: lockfiles on braces, David W. Tamkin <=