CCL Home Page
Up Directory CCL lock
#include "utility.h"
#include 
#include 
#include 

int lock(lock_file_name)
/*============================================================================*/
/* PURPOSE: ACQUIRE A SEMAPHORE TYPE FILE LOCK ON THE NAMED FILE.
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
   char lock_file_name[];	/* NAME OF LOCK FILE. */
   {
   int fd;			/* FILE DESCRIPTOR. */
   int ntry;			/* WHICH TRY WE ARE ON. */

   extern int errno;

   ntry=0;

   while ((fd=creat(lock_file_name,0))== -1 && errno==EACCES)
      {
      if (++ntry >= 3) return(FALSE);
      sleep(5);
      }

   if (fd== -1 || close(fd)== -1) return(FALSE);
   else return(TRUE);
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 5093 times since Sat Apr 17 21:58:57 1999 GMT