Subject: Re: What does POSIX say about this?
To: Niklas Hallqvist <>
From: Greg Cronau <>
List: current-users
Date: 06/14/1994 07:03:45
Niklas Hallqvist
>I have no POSIX spec of any kind, so I'd appreciate if someone looks
>my question up.
>What should a F_UNLCK fcntl SET_LK op return if we're unlocking a non-locked
>area?  NetBSD, SVR3 & SVR4 returns 0 and just ignores the op.  Linux returns
>EINVAL.  Who is right, in terms of POSIX-compliance?  If you got an answer
>please refer to chapter & verse of some POSIX doc.

I looked this up in the O'Reilly _Posix Programmer's Guide_. The command
is "F_SETLK" under Posix, by the way. I could find no explicit description
of what the behaviour of the above should be. However, I think we could
imply from the following paragraph...

   F_SETLK  The third argument must be a pointer to a "struct flock". The
            lock is set or cleared according to the function code in the l_type
            member. If the lock is busy, fnctl() returns -1 and sets errno to
            EACCES or EAGAIN.

...that NetBSD, SVR3, & SVR4 are Posix compliant. Note that the returned
error values can be inferred to apply to *either* a set or clear operation,
and that the defined error code is only returned if the lock is busy. Since
the area was not locked in the first place, it can never be busy.

Just my opinion