..and so here is a tiny manual update.
Just noting that locking succeeds on at least (my outdated) Snow
Leopard and i like that since /dev/null is the only sane, always
available option to foist something NULLy into whatever.
I.e., i use it to be able to have an available NULL mailbox for
the test (suite is a wording too strong, still). Yes, it is
because the BSD Mail codebase i'm sitting upon still doesn't have
it own VOID object that can be addressed directly.
--steffen
--- dfly-fcntl.2.orig 2015-07-17 20:48:35.000000000 +0200
+++ dfly-fcntl.2 2015-07-17 21:23:46.000000000 +0200
@@ -529,9 +529,11 @@ is
.Dv F_SETLK
or
.Dv F_SETLKW
-and the data to which
+and either the data to which
.Fa arg
-points is not valid.
+points is not valid or the file type backed by
+.Fa fd
+doesn't support file locking operations.
.It Bq Er EMFILE
The argument
.Fa cmd
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main(void)
{
struct flock flp;
FILE *fp;
int rv;
fp = fopen("/dev/null", "r");
if (fp == NULL) {
rv = 1;
goto jleave;
}
memset(&flp, 0, sizeof flp);
flp.l_type = F_RDLCK;
flp.l_start = 0;
flp.l_whence = SEEK_SET;
flp.l_len = 0;
rv = (fcntl(fileno(fp), F_SETLK, &flp) != -1) ? 0 : 2;
fclose(fp);
jleave:
return rv;
}