mutex_lock_interruptible(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… mutex_lock_interruptible(9) πŸ’…

okay bestie, welcome to the Kernel API Manual β€” yes, the actual manual, section 9, and we are about to talk about mutex_lock_interruptible, which is giving "lock me up but only if you're sure" energy. let's go πŸŽ€


✨ NAME ✨

mutex_lock_interruptible β€” Acquire the mutex, interruptible by signals.

like, you want the mutex, but you're also lowkey open to being interrupted by a signal. main character with boundaries, honestly.


🌸 SYNOPSIS 🌸

int mutex_lock_interruptible (struct mutex *lock );

that's it. that's the whole vibe. one argument, returns an int, no cap. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • lock β€” The mutex to be acquired. literally the thing you're trying to grab. hand it over and hope for the best 🫢

πŸ’– DESCRIPTION πŸ’–

Lock the mutex like mutex_lock. same energy, same intent, same "i need this resource" desperation.

but here's the plot twist: if a signal is delivered while the process is sleeping, this function will return without acquiring the mutex. 😭

so yeah, unlike plain mutex_lock you can get woken up by a signal and just... not get the lock. it's giving "i was gonna commit but then my phone rang" and honestly? iconic behaviour for an interruptible function. ✨


🌈 CONTEXT 🌈

Process context. (not interrupt context, not atomic context, don't try it β€” this is a "process is sleeping and can be woken" situation, iykyk) πŸ’œ


⭐ RETURN ⭐

  • 0 β€” if the lock was successfully acquired. slay, you got it. πŸ‘‘
  • -EINTR β€” if a signal arrived. not your fault bestie, the signal really said "not today" πŸ’€

so like, always check the return value, fr fr. zero means you own the mutex now, -EINTR means you do not own the mutex and should probably bail out gracefully. no guessing, that's literally what the manpage says.


πŸ”₯ SEE ALSO πŸ”₯

all the related lore, straight from the kernel, no edits:

like a whole friend group of mutex functions, all linked in the group chat. 🧚


okay that's the whole page bestie β€” go forth and lock responsibly. 🌸

this little love letter came from the ./kernel/locking directory, dated October 2026, and it's the mutex_lock_interruptible(9) page from the Kernel API Manual. mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from