Re: flock, FAGAIN, and FWOULDBLOCK

Michael Kerrisk
2009-02-23T03:31:18Z

On 2/23/09, Carlos O'Donell <carlos@systemhalted.org> wrote:
> On Sun, Feb 22, 2009 at 8:42 PM, Kyle McMartin <kyle@infradead.org> wrote:
>>> Definitely a kernel bug, if posix says it should return EWOULDBLOCK...
>
> flock is not POSIX, it's an interface invented by 4.2BSD, and was
> previously emulated by glibc. The glibc wrapper implemented flock with
> fcntl and made sure to return EWOULDBLOCK.
>
>> This is really going to suck, it looks like a lot of the locking
>> primitives used EAGAIN and EWOULDBLOCK interchangeably... The fcntl
>> manpage says 'EAGAIN or EWOULDBLOCK' so is flock(2) the only problem
>> here? From a quick glance at posix, fcntl(2) returning EAGAIN is
>> correct.
>
> I would warn you that the linux man pages are often incorrect.

Hmmm -- "often" is rather strong. I will certainly allow
"occasionally" (or perhaps a little more), and I note in passing that
for someone making the claim of "often", I never saw a patch from you
so far to correct an error...

Cheers,

Michael