poll_timeout_us(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… poll_timeout_us(9) β€” from the Kernel API Manual, bestie

okay so picture this: you're in kernel land, you've got an operation, you've got a condition, and you're just gonna sit there polling like a patient little angel until the condition hits or the clock runs out. that's the whole vibe of poll_timeout_us. it's giving "are we there yet" but make it ✨systems programming✨.


✨ NAME ✨

poll_timeout_us β€” periodically poll and perform an operation until a condition is met or a timeout occurs πŸŽ€

like, it keeps doing The Thing, over and over, until either the condition says "we're done babe" or the timeout says "time's up sweetie." no cap.


🌸 SYNOPSIS 🌸

poll_timeout_us (op , cond , sleep_us , timeout_us , sleep_before_op );

that's the whole signature, crown and all πŸ‘‘ β€” copy it exactly, don't get cute with it.


πŸ¦‹ ARGUMENTS πŸ¦‹

  • op β€” Operation. the thing you want to keep doing. the main character of the loop πŸ’…
  • cond β€” Break condition. when this goes true, we're out, we're done, we're free πŸ•ŠοΈ
  • sleep_us β€” Maximum time to sleep between operations, in us. and 0 means tight-loops β€” like, no sleeping at all, just absolutely feral spinning 😭. please read the usleep_range function description for details and limitations, fr fr, don't skip it.
  • timeout_us β€” Timeout in us. and 0 means never timeout β€” it'll wait, like, forever, bestie. iconic of it honestly.
  • sleep_before_op β€” if it is true, sleep sleep_us before the operation. like stretching before the gym, but for polling 🧚

πŸ’œ DESCRIPTION πŸ’œ

okay so real talk: when available, you'll probably want to use one of the specialized macros defined below rather than this macro directly. that's not me being shady, that's just the manpage being honest πŸ™ˆ β€” this one's the general-purpose girlie, the specialized ones are the specialists.


🌈 RETURN 🌈

  • 0 on success β€” slay, we got there πŸŽ‰
  • -ETIMEDOUT upon a timeout β€” the clock said no ❌
⚠️ ok this part is IMPORTANT, listen up: it must not be called from atomic context if sleep_us or timeout_us are used. like, don't do it. that's a you-problem you do not want πŸ’€. atomic context + sleeping = bad time, no notes.

⭐ SEE ALSO ⭐

the whole friend group, honestly 🫢 all of them.


and that's the tea, bestie β€” this page lives at ./include/linux, dated October 2026, and it's filed under poll_timeout_us(9). go poll responsibly, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from