diff --git a/lib/util.C b/lib/util.C index 0ea9a32697..40f6acc8e0 100755 --- a/lib/util.C +++ b/lib/util.C @@ -155,14 +155,14 @@ int lock_file(char* filename) { int retval; // some systems have both! +#ifdef HAVE_FLOCK + int lock = open(filename, O_WRONLY|O_CREAT, 0644); + retval = flock(lock, LOCK_EX|LOCK_NB); +#else #ifdef HAVE_LOCKF int lock = open(filename, O_WRONLY|O_CREAT, 0644); retval = lockf(lock, F_TLOCK, 1); // must leave fd open -#else -#ifdef HAVE_FLOCK - int lock = open(filename, O_WRONLY|O_CREAT, 0644); - retval = flock(lock, LOCK_EX|LOCK_NB); #endif #endif