Aggiunte e correzioni alle funzioni per i file di lock
[gapil.git] / sources / wrappers.h
index 15ddd826c2f3500668632b8d1cea932e6a95fef1..ed4a19b32f06b190ead58071714cdef518df0aa3 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Author: S. Piccardi
  *
- * $Id: wrappers.h,v 1.4 2002/11/20 23:34:02 piccardi Exp $
+ * $Id: wrappers.h,v 1.5 2002/12/02 23:06:59 piccardi Exp $
  *
  ***************************************************************/
 #include <sys/sem.h>     /* IPC semaphore declarations */
@@ -161,24 +161,18 @@ inline char * ShmFind(key_t ipc_key, int shm_size)
     return shptr;
 }
 /*
- * Function LockFile:
- * Create a lockfile of the given pathname.
+ * Function LockFile & UnlockFile:
+ * Create and remove a lockfile of the given pathname.
  * Fail and exit in case of error or existence of the same lock 
  * file, using unlink do not need to remove the file,
  */
-inline void LockFile(const char* path_name) 
+inline int LockFile(const char* path_name) 
 {
-    if (open(path_name, O_EXCL|O_CREAT)<0) {
-       perror("Already active");
-       exit(1);
-    } 
+    return open(path_name, O_EXCL|O_CREAT);
 }
-inline void UnlockFile(const char* path_name) 
+inline int UnlockFile(const char* path_name) 
 {
-    if (unlink(path_name)) {
-       perror("error, cannot unlink");
-       exit(1);
-    }  
+    return unlink(path_name);
 }
 /*
  * Function Signal