Re: flock, FAGAIN, and FWOULDBLOCK

Kyle McMartin
2009-02-23T02:54:22Z

On Sun, Feb 22, 2009 at 09:43:36PM -0500, Carlos O'Donell wrote:
> 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.
>

Right, I had confused flock and flockfile in the index.

> > 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.
>
> I use http://www.opengroup.org/onlinepubs/009695399/ for check POSIX
> requirements.
>

I wouldn't be nearly so negative.

> A more robust solution would be?
>
> if ((ret == -EAGAIN) || (ret == -EWOULDBLOK))
> ret = -EWOULDBLOCK
>
> This covers our ass since POSIX says that EAGAIN and EWOULDBLOCK *may*
> be the same.
>

I have no idea what you're on about here, this is a parisc specific
file, where we know they aren't. I don't want to pollute generic linux
code with workarounds for moronic HPUX "let's be different for
difference sake" crap.

> > but somehow I suspect this interchangeable use of EAGAIN and EWOULDBLOCK
> > is going to reveal latent problems in this part of the kernel I would
> > rather not delve into...
>
> The ABI is fixed, so all we can do is cleanup the uses in the kernel,
> and make sure we adhere to the documented APIs.
>

I ain't volunteering...

> Don't get too upset ;-)