[comp.emacs] movemail and file locking

worley@compass.UUCP (Dale Worley) (11/23/88)

Do be careful when you're dealing with movemail!  The problem is that
there are two completely different methods that sendmail uses to
interlock mail handling (depending on your system type), and movemail
must use that method also.  This is controlled by MAIL_USE_FLOCK.  If
it's defined, movemail uses the flock() system call to interlock, and
if it's not, movemail creates lock files.  If you're using flock(),
movemail needn't be setuid.

As far as I know, BSD systems use flock, and System V systems use lock
files.

Unfortunately, in NFS (or at least, Sun NFS), the flock() call is not
system-wide, it is only known on the local host.  Sun did provide the
lockf() call which is system-wide, so you have to do your locking
different ways depending on what sort of file system you've got.  And
as far as I can tell, you can't use lockf to fake up a system-wide
flock, since they are inherited differently by child processes.  Yuck.

Also, apropos complaints about Emacs's locking files being edited --
perhaps they should be implemented using flock (or lockf) on systems
that support it?  This solves the clean-up problem.

Dale