cat_lockfile - lock an open, writeable file.
#include <cat/catutil.h>
int cat_lockfile(FILE *f, int nowait);
Locks an open, writeable file referenced by f. If the file is already locked and nowait is set to 0, the calling thread is suspended until the lock on the file is
released. If the file is locked and nowait is non-zero, the function return with CAT_EAGAIN.
The lock is an advisory lock, which means that any other process that does
not use this locking mechanism is free to alter the file.
Returns zero if successful or a negative code on error.
This locking function should not be assumed to be compatible with any other
file locking function.
(UNIX only) Due to the semantics of POSIX file locking, a lock can be
released if another file descriptor, referring to the same file on disk, is
closed in the same process.
cat, catutil, cat_filelength, cat_filetime,
cat_getfile, cat_truncatefile, cat_unlockfile