X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2Fwrappers.h;h=ed4a19b32f06b190ead58071714cdef518df0aa3;hp=15ddd826c2f3500668632b8d1cea932e6a95fef1;hb=78a82bdb333ca71e395ba39a5c03745761341150;hpb=4263734ffe237b1a7249c1f8121bb7ebe8b60a50 diff --git a/sources/wrappers.h b/sources/wrappers.h index 15ddd82..ed4a19b 100644 --- a/sources/wrappers.h +++ b/sources/wrappers.h @@ -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 /* 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