Holger responded,
| Couldn't one simply check whether the lockfile already exists,
| and if not, go into a block where it's created?
|
| :0 flags
| * conditions
| * ! ? test -f lockfilename
| {
| :0 flags_for_action :lockfilename
| action
| }
Well, you can write that without the braces, and it needs a w or W so that
a process that gets the lock won't give it up until the action is done:
:0w flags_for_conditions other_flags_for_action :lockfilename
* other conditions
* ! ? test -f lockfilename
action
You're still calling either /bin/test or a shell (or if /bin/test is a shell
script, both), so it still uses something outside procmail. It does elimi-
nate the need to call rm, though.
| This would fail if just between the test and the creation of the
| lockfile another procmail interfered and created the lockfile on
| its own, but is that danger big enough to worry about? Or am I
| overlooking something else?
No, that's pretty much it, avoiding race conditions. The whole question is
one of avoiding race conditions, after all. You've shown a way to reduce
the possibility of a race condition, but it didn't eliminate it, and it still
calls another program (one fewer than my earlier code, however).