NAME
dotlock - create lock files
SYNOPSIS
dotlock [-f] lock-file program [arg] [arg] ...
DESCRIPTION
The dotlock program creates a lock file that's compatible with maildrop, and other mail software, then runs a program. When the program terminates, the lock file is removed.
Because a mailbox file can only be accessed by one program at a time, a lock file must be used by all programs who need to use the mailbox file. Otherwise, while one program uses a mailbox file, another program can write to it, resulting a corrupted mailbox. dotlock creates a dot-lock file by default. Specifying the -f option will create an flock lock instead (the file is opened, and the flock() system call is used to obtain a lock on the file).
Please note that you must specify the full name of the lock file, including the ".lock" extension. Therefore, to lock /var/spool/mail/user, you must specify /var/spool/mail/user.lock as the lock file. If you omit the .lock extension, you'll end up deleting your mail!