[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: open - resource temporarily unavailable



On 2016-06-17 13:31 +0200, tomas@tuxteam.de wrote:

> OK. I've got one more hint. Reading through the open(2) man page
> (assuming it is really open what's failing on you -- what evidence
> do you have?), EAGAIN isn't listed among the possible errno values,
> but EWOULDBLOCK
>
>    EWOULDBLOCK
>           The O_NONBLOCK flag was specified, and an incompatible
>           lease was held on the file (see fcntl(2)).

Thanks, I had only looked at EAGAIN.

> Now, on POSIX systems EWOULDBLOCK and EAGAIN could be one and the
> same.

On Linux, EWOULDBLOCK is #defined as EAGAIN in asm-generic/errno.h.
Also they are always the same in the glibc, regardless of the operating
system kernel.

> Lo and behold, a small test program on my box reveals that
> both at least translate to 'Resource temporarily unavailable':
>
>     #include <stdio.h>
>     #include <errno.h>
>     #include <string.h>
>     
>     int main(int argc, char *argv[])
>     {
>      printf("EAGAIN is '%s'\n"
>             "EWOULDBLOCK is '%s'\n",
>             strerror(EAGAIN),
>             strerror(EWOULDBLOCK));
>     }
>     
>     ==>
>     
>     tomas@rasputin:~/prog/C$ ./errno
>     EAGAIN is 'Resource temporarily unavailable'
>     EWOULDBLOCK is 'Resource temporarily unavailable'

You don't have to write your own program, there is already an 'errno'
utility in the moreutils package. :-)

Cheers,
       Sven


Reply to: