io_canread(3)
π io_canread β bestie, which fd is ready to spill the tea?
okay so real quick, we're in the Library Functions Manual section, page io_canread(3), and it is exactly what it sounds like: it tells you which file descriptor is ready to be read from. no cap. β¨
πΈ NAME πΈ
io_canread β return a file descriptor that can be read from π«Ά
β¨ SYNTAX β¨
#include <libowfat/io.h>
int64 io_canread();
that's it, that's the whole signature. int64, no args, she's lowkey elegant π
π¦ DESCRIPTION π¦
so io_canread hands you back the next file descriptor that can be read from. but bestie, there are receipts you gotta have first: you have to have called io_wantread() on that file descriptor earlier, and you have to have called io_wait() or io_waituntil(). no skipping steps, the vibes must be correct. π
what happens under the hood is these functions keep an internal data structure β like a little group chat β of which descriptors the operating system reported as readable. it's giving main character energy for your fds. π
β οΈ super important, don't skip this one: there is no guarantee that there's still data you can read from the descriptor. all it means is that there was data back whenio_wait()orio_waituntil()got called. another process could've swooped in and read the data before you even got there. π so literally always look at the result fromio_tryread().
and if there are no more descriptors that you can write to without blocking, io_canwrite will return -1. when that happens, you should call io_wait() or io_waituntil() again. just loop back around, queen. π
also β and this is the part people get wrong β you should use io_tryread(3) to read from the descriptor, not plain read(2). if you do use read(2) and you get EAGAIN, call io_eagain(3). please. for me. π
π SEE ALSO π
and that's the whole page, bestie!! this little icon was brought to you by the io_canread(3) page from the Library Functions Manual β go forth, check your fds, and slay πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms