wait_event_interruptible(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ‘‘ wait_event_interruptible β€” the kernel API manual, bestie edition πŸ’…

okay so real talk, this page is wait_event_interruptible(9) from the Kernel API Manual (section 9, iykyk) β€” and it's literally the "go to sleep but wake up if someone pokes you" function. let's get into it 🫢


✨ NAME ✨

wait_event_interruptible β€” sleep until a condition gets true πŸ˜΄βž‘οΈβœ…


🌸 SYNOPSIS 🌸

wait_event_interruptible (wq_head , condition );

πŸŽ€ ARGUMENTS πŸŽ€

  • wq_head β€” the waitqueue you're gonna wait on. that's the spot you're camping out at, babe β›Ί
  • condition β€” a C expression for the event you're waiting for. the "am I awake yet?" check πŸ’­

πŸ¦‹ DESCRIPTION πŸ¦‹

so the process gets put to sleep β€” specifically in TASK_INTERRUPTIBLE state β€” until either the condition evaluates to true ✨ or a signal shows up πŸ“¬. and the condition gets checked every single time the waitqueue wq_head is woken up. every time. no cap.

the important bit, do not skip this: wake_up has to be called after changing any variable that could change the result of the wait condition. like, you change the thing, you call wake_up. that's the deal. fr fr πŸ”₯

the function returns -ERESTARTSYS if it got interrupted by a signal 😭, and 0 if condition evaluated to true πŸŽ‰.


πŸ’œ SEE ALSO πŸ’œ

kernel file ./include/linux/wait.h, plus the whole friend group:


and that's the whole page, bestie β€” brought to you straight out of ./include/linux, dated October 2026, slaying as always πŸŒˆπŸ’– periodt.

πŸ“¦ where this page comes from