* Include <sys/file.h>, not <fcntl.h>, the flock(2)
* #defines were found there on historical systems.
* Use fcntl(2) locking to fake flock(2) locking.
* DO NOT USE fcntl(2) UNLESS YOU HAVE TO, THERE ARE SOME SYSTEMS
* (I.E. ULTRIX) WHERE LOCKS AREN'T RELEASED WHEN PROCESSES DIE.
switch (operation
& ~LOCK_NB
) {
arg
.l_start
= arg
.l_len
= 0;
arg
.l_whence
= 0; /* SEEK_SET */
if (!fcntl(fd
, operation
& LOCK_NB
? F_SETLK
: F_SETLKW
, &arg
))
if (errno
== EACCES
|| errno
== EAGAIN
)