top | item 27216534

(no title)

moises_silva | 4 years ago

> No new code should be using select(). Using it assumes the execution environment keeps all file descriptor values within FD_SETSIZE.

I'm with you here. I'm also guilty of using it still for some CLI tools or other small programs. Just to be clear you don't need to assume all fd values will stay within FD_SETSIZE. Just that the fds you will use with select will stay in that range. Even if there will be lots of fds (more than FD_SETSIZE) for other resources, it works for example to select on stdin if you're not doing funny business reopening it.

There's no much of an excuse to keep using it though other than laziness.

discuss

order

bvrmn|4 years ago

Laziness is pretty good reason to continue to use select. It's a convenient interface for simple tasks. The very nature of fire a set of fds and get a result beats (e)poll/kqueue/fd-registering based API in UX regard. It's sad there is no alternative with same simple interface and without FD_SETSIZE shortcoming.

Edit: I'm biased by Python which has `select.poll` with API similar to epoll and it's really hard to use it instead of select.

megous|4 years ago

poll() is even easier to use, imo.