Subject: Re: Lock Files

From: [email-masked] (David W. Tamkin)
Date: Thu, 16 Mar 1995 23:07:19 -0600 (CST)

Mark Bynum asked,

| My question is about lock files.  First of all why are the needed? 

They are needed to keep two processes from altering the same file at the same
time.

In the most common case, suppose you receive two letters simultaneously that
are destined for the same folder.  You now have to invocations of procmail
running at the same time, both writing to the same file at the same time.
They both append to the folder and the text of the two letters mixes together
inextricably.

| Does it
| mean that if you have a global (or default) lock file then only one instance
| of procmail at a time can be invoked by you?  What does this buy you? 

That's close: it actually means that the second instantiation of procmail
will wait for the first one to exit before it does anything on its own.  A
global lockfile will not prevent the second procmail from starting, but it
will make it wait.  What it buys you is that the two won't interfere.

| For a local lockfile (one for each different action in .procmailrc) does this
| mean that only one instance of it can occur at the same time?  Why would you
| need this?

A local lockfile means that two or more instantiations of procmail can run at
the same time as long as they're doing things that don't interfere with one
another.  If, for a simple example, you subscribe to the Geniuses' List and to
the Intelligentsia List, and one letter from each list comes in at the same
time, but your .procmailrc saves one to $MAILDIR/geniuses and the other to
$MAILDIR/intelligentsia, the two invocations of procmail can run at the same
time and save their letters to the right folders.  But if two letters from
the Geniuses' List come in at the same time, a local lockfile will prevent
them from clobbering one another or mixing together.

If you always save mail to individual files (such as MH folders) you rarely
need lockfiles if at all.  But if you use standard mail folders they're
indispensable.