mutex_lock_interruptible(9)
π 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:
- Kernel file
./kernel/locking/mutex.c mutex_lock(9)mutex_unlock(9)ww_mutex_unlock(9)ww_mutex_trylock(9)mutex_lock_killable(9)mutex_lock_io(9)mutex_trylock(9)atomic_dec_and_mutex_lock(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms