Subject: Re: lockfile with forked process?

From: [email-masked] (David W. Tamkin)
Date: Fri, 24 Jun 1994 20:36:40 -0500 (CDT)

Jonathan Rochkind was asking,

| In the .procmailrc, what exactly does it mean if you use a lockfile
| with a pipe?

The same as on any recipe: if the conditions pass and procmail attempts the
action of that recipe, it will create a local lockfile and, if one already
exists, wait until it is gone or stale (staleness usually means seventeen
minutes old) before creating its own and performing the action.

| For instance:
| :0:
| * something-or-other
| | myscript
|  
| What does that mean? What name does it use for the lockfile?

Well, there's the problem.  It has no name for the lockfile and will give an
error message.  If the recipe were like this:

 :0:
 * something-or-other
 | myscript >> myscript_output

it would use $MAILDIR/myscript_output.lock because procmail looks for ">>"
in a pipe recipe when it has to figure out its own name for a local lockfile.

If the recipe were like this:

 :0:myscript.lock
 * something-or-other
 | myscript

it would use $MAILDIR/myscript.lock as the local lockfile.

| Or does it use a lockfile at all?

I think it doesn't because it has no name for the local lockfile.  You'll
get a "cannot determine implicit name of local lockfile" error.

| What's the difference between that, and the same
| thing without the final colon to signify a lockfile being used?

If you don't have the second colon, procmail will execute the action without
a local lockfile.  Suppose two letters that match the condition(s) come in at
the same time and two invocations of myscript are running.  Now, I don't know
what 'myscript' does.  If it's something of which multiple invocations can be
safely run simultaneously, forget the local lockfile; it's a waste of effort.
If it would be a problem to run two invocations of myscript simultaneously
(say, they both append to the same file and text from the two would mix),
then the local lockfile is necessary.

So if you need the local lockfile, the difference is that without it you'll
risk getting text intermixed or clobbered.  If you don't need it, the
difference is that you'll be wasting cycles to create and remove it and
even more if procmail has to wait to create it.

David W. Tamkin  P. O. Box 3284  Skokie IL  60076-6284
[email-masked]   MCI Mail: 426-1818   +1 312 714 5610