des@gmail.com wrote: >At the start of the program create a file if it does not exist and at >the end delete a file. If the file exists, then exit program.

And what if the program crashes or gets interrupted? That way, the lockfile would never be deleted.

And you have a race condition, between testing if the file exists, and actually creating it (unless you're openign the file with the O_EXCL flag (from Fcntl), which somehow I doubt.) (see http://bama.ua.edu/cgi-bin/man-cgi?open+2)