Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Oh the real fun thing is when the select() is not even in your code! I remember having to integrate a closed-source third-party library vendored by an Australian fin(tech?) company which used select() internally, into a bigger application which really liked to open a lot of file descriptors. Their devs refused to rewrite it to use something more contemporary (it was 2019 iirc!), so we had to improvise.

In the end we came up with a hack to open 4k file descriptors into /dev/null on start, then open the real files and sockets necessary for our app, then close that /dev/null descriptors and initialize the library.




There's no need to actually do all the opening if you control the code.

You can do anything with `fcntl(F_DUPFD{,_CLOEXEC})` and `fdopen`.


If we had control of library code, we'd just get rid of select()...

Though we did use the dup trick in another case!




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: