HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/qlibs/lock.c
#include <unistd.h>
#include <sys/types.h>
#include <sys/file.h>
#include <fcntl.h>
#include "lock.h"

/**
	@file lock.c
	@author djb
	@source qmail
	@brief locking of resources
*/

#ifdef HASFLOCK
int lock_ex(int fd) { return flock(fd,LOCK_EX); }
int lock_exnb(int fd) { return flock(fd,LOCK_EX | LOCK_NB); }
int lock_un(int fd) { return flock(fd,LOCK_UN); }
#else
int lock_ex(int fd) { return lockf(fd,1,0); }
int lock_exnb(int fd) { return lockf(fd,2,0); }
int lock_un(int fd) { return lockf(fd,0,0); }
#endif