lockmail is a helper utility for working with mailbox files. Mailbox files must be locked to prevent other applications from modifying the mailbox at the same time. Different system use different locking conventions. lockmail uses two of the most common locking mechanisms in use, which should work reliably on most systems.
lockfile is the pathname to an existing mailbox file. By default, lockmail tries to lock the mailbox every five seconds (if the mailbox is already locked), and will give up after three minutes. After the mailbox is succesfully locked, lockmail runs program as a child process, with any optional arguments. When program terminates, lockmail removes the mailbox lock, and terminates itself.
If a regular lock fails, try a read-only lock. Use this option to lock mailbox files in a read-only directory.
If the lock attempt fails, try again for up to timeout seconds. The actual timeout is rounded up to the next five second interval (a lock attempt is tried every five seconds).