lock_file

    #include <mplib1/lock_file.h>

    int lock_file( const char *filename );
This function provides a simple means of controlling access to a single resource, or a method of ensuring that only instance of a program exists at any one time.

The routine attempts to open the filename provided, lock it, truncate it, write the current pid into it, and mark the file as close on exec. If all of these succeeds, the function returns 1. If any fail, the file is closed and the function returns 0.