#include #include "shared_util.h" /* for cs_critical_error() */ #include "shared_lock.h" #include "shared_cs_util.h" /* for cs_critical_error() */ int get_shared_lock(int fd, int report_error) { int error = flock(fd, LOCK_SH); if(error && report_error) cs_critical_error(ERR_FLOCK_SHARED_FAILED, ""); return error; } int get_exclusive_lock(int fd, int report_error) { int error = flock(fd, LOCK_EX); if(error && report_error) cs_critical_error(ERR_FLOCK_EXCLUSIVE_FAILED, ""); return error; } void release_lock(int fd) { if(flock(fd,LOCK_UN)) cs_critical_error(ERR_FLOCK_UNLOCK_FAILED, ""); }