TERMKEY_ADVISEREADABLE(3)
π TERMKEY_ADVISEREADABLE π
okay bestie, so this one lives in the Library Functions Manual section 3, and it's called termkey_advisereadable β the little function that goes "hey girl, there might be more bytes waiting for you on that terminal" π¦
β¨ NAME β¨
termkey_advisereadable β read more bytes from the underlying terminal π
πΈ SYNOPSIS πΈ
#include <termkey.h>
TermKeyResult termkey_advisereadable(TermKey *tk);
Link with -ltermkey.
π DESCRIPTION π
so like. termkey_advisereadable() is literally just you tapping your termkey(7) instance on the shoulder like "bestie, new input might be available on the underlying file descriptor, go call read(2) and get it" πβ¨
Here's the vibe check on what comes back:
- If it read at least one more byte, it returns
TERMKEY_RES_AGAINβ which is code for "it may be useful to calltermkey_getkey(3)again" π - If no more input was read, you get
TERMKEY_RES_NONEπΆ - If there was no buffer space remaining, you get
TERMKEY_RES_ERRORwitherrnoset toENOMEMπ - If there's no filehandle associated with this instance, you get
TERMKEY_RES_ERRORwitherrnoset toEBADFπ
This function, together with termkey_getkey(3), is what makes it possible to use the termkey instance in an asynchronous program. And if you wanna feed it bytes without using a readable file handle, use termkey_push_bytes(3) instead, okay? π«Ά
For synchronous usage, termkey_waitkey(3) is the one doing the input blocking task, no cap.
β RETURN VALUE β
termkey_advisereadable() returns one of these constants, and they're all giving very specific energy:
TERMKEY_RES_AGAINβ at least one byte was read β¨TERMKEY_RES_NONEβ no more bytes were read πTERMKEY_RES_ERRORβ an IO error occurred.errnowill be preserved. And here's the important part, so listen up: if the error isEINTRthen this will only be returned if theTERMKEY_FLAG_EINTRflag is not set; if it is set then the IO operation will be retried instead ππ
π SEE ALSO π
and that's the whole page, bestie β it's from the TERMKEY_ADVISEREADABLE(3) entry in the Library Functions Manual, and it's literally iconic. mwah π πβ¨
π¦ where this page comes from
- alpine 3.24: libtermkey-doc 0.22-r4 Β· MIT
- debian trixie: libtermkey-dev 0.22-2+b1 Β· MIT
- epel 10: libtermkey-devel 0.22-2.el10_0 Β· MIT
- epel 9: libtermkey-devel 0.22-2.el9 Β· MIT
- fedora 43: libtermkey-devel 0.22-11.fc43 Β· MIT
- fedora 43: libtermkey-devel 0.22-11.fc43 Β· MIT
- fedora 44: libtermkey-devel 0.22-12.fc44 Β· MIT
- fedora 44: libtermkey-devel 0.22-12.fc44 Β· MIT
- nixos 26.05: libtermkey 0.22
- nixpkgs unstable: libtermkey 0.22
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- ubuntu questing: libtermkey-dev 0.22-2
- ubuntu resolute: libtermkey-dev 0.22-2build1 Β· MIT
- ubuntu stonking: libtermkey-dev 0.22-3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms