Re: Does the `select.2` ignore the `O_NONBLOCK`?

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

 



Hello Robin,

On 15 May 2018 at 22:10, Robin Kuzmin <kuzmin.robin@xxxxxxxxx> wrote:
> Michael,
> Is the assumption correct that `select.2` ignores the `O_NONBLOCK`
> flag in the file descriptors it operates on?
>
> Details:
> I assume that `select.2`
> (http://man7.org/linux/man-pages/man2/select.2.html) completely
> ignores the fact that some (or all) of the file descriptors (the
> `select.2` operates on) can be marked as non-blocking (O_NONBLOCK).
>
> I mean if
> + the `select()` is called for a single socket,
> + and that socket is non-blocking,
> + and the `select()` time-out is non-zero,
> then
> + `select()` will not return immediately (returning (-1) and `errno`
> equal to `EWOULDBLOCK` or `EAGAIN`)
> + but will be suspended for the duration of the `select()` time-out.
>
> If the assumption is correct then it would save me some time if I saw
> an explicit note about that in
> http://man7.org/linux/man-pages/man2/select.2.html.

I added this text to the description of O_NONBLOCK in open(2):

              Note  that  ithe  setting of this flag has no effect on the
              operation of poll(2),  select(2),  epoll(7),  and  similar,
              since  those  interfaces  merely  inform  the  caller about
              whether a file descriptor is "ready", meaning that  an  I/O
              operation  performed on the file descriptor with the O_NON‐
              BLOCK flag clear would not block.

This seems better than a note in select(2), since there are several
related APIs where people might be confused about this point.

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux