4 ms·
Select has 1024 bit/file descriptor bitmap and anyone using it gets what they deserve. MacOS also provides poll() as a slightly less braindead, but still POSIX
by crest 3y ago
Select has 1024 bit/file descriptor bitmap and anyone using it gets what they deserve. MacOS also provides poll() as a slightly less braindead, but still POSIX option. The proper solution is to use kqueue()/kevent() allowing userspace processes to efficiently get notified about changes to tens of thousands of file descriptors (tracking a million file descriptors using this API on FreeBSD works fine).
- kevincox 3y agoI don't know if I would call anyone unfortunate enough to not know about the limitations of select() deserving of such limitations. At least on my Linux box the man page does have a warning at the top of the description section but it is easy to accidentally skim over. It would be interesting to do something like avoid defining that symbol by default, require `-DENABLE_OBSOLETE_SELECT_API` to make it available. It would cause trouble for compiling old software but it is easy to remedy and at least makes new users extra aware that they shouldn't start using this function.
- avhception 3y agoUnfortunately, adding in an option like `-DENABLE_OBSOLETE_SELECT_API` is only trivial if you have a good understanding of the build system in use and sometimes other nuts and bolts of a given project. Tracking down a build failure in some old software project that may or may not have approachable people left on the team through elaborate build scripts that may or may not surface the error in a way that may or may not be easily comprehensible for an outsider can be really hard.
- rollcat 3y agoApropos Macs and man pages, does anyone know if there's any up-to-date website that allows browsing them online? Like https://man7.org/linux/man-pages/ https://man7.org/linux/man-pages/ or https://man.openbsd.org https://man.openbsd.org, ideally per release and per architecture.
- throw0101a 3y ago* https://keith.github.io/xcode-man-pages/ https://keith.github.io/xcode-man-pages/ * https://github.com/keith/xcode-man-pages https://github.com/keith/xcode-man-pages ?
- pjmlp 3y agoI expect anyone coding UNIX systems to have more sources than only man pages, like classic UNIX books.
- mort96 3y agoI like using poll(). I don't generally write software which waits for tens of thousands of FDs, I wait for a couple. Sacrificing platform support for more or less nothing in return doesn't make a lot of sense. Kqueue/kevent/epoll are good options if you have very particular needs, such as a huge number of file descriptors, but I'd argue poll() should be the go-to.
- arghwhat 3y agoYou get kqueue and epoll for free with most small event loop libraries. But yes, where you only need to poll a few things, poll(3) is fine.
- mort96 3y agoI guess if you're using an event loop library you don't have to think about it. For people who make event loop libraries, I agree that they should probably support kqueue/kevent+epoll. I was talking about normal application code that's not using such an event loop library.