syscall_get_nr(9)
β¨ syscall_get_nr(9) β¨
okay so this is a page from the Kernel API Manual (section 9, kernel-land, very demure very mindful) and it's literally about figuring out which syscall a task is currently vibing in π
πΈ NAME πΈ
syscall_get_nr β find what system call a task is executing
π SYNOPSIS π
int syscall_get_nr (struct task_struct *task , struct pt_regs *regs );
π¦ ARGUMENTS π¦
taskβ the task of interest. bestie it must be blocked, no exceptions, that's the whole vibe check π«Άregsβ this istask_pt_regsoftask. like, the registers of that task specifically, not some random other task's, iykyk
π DESCRIPTION π
so here's the tea β if task is executing a system call, or it's at system call tracing about to attempt one, this returns the system call number. slay, that's it, that's the number π₯
but if task is not executing a system call β meaning it's blocked inside the kernel for a fault or a signal β then it returns -1. like, nothing's happening, no syscall, no number, just -1 π
β οΈ okay important detail: this returnsinteven on 64-bit machines. only 32 bits of system call number can be meaningful. so if the actual arch value is 64 bits, this truncates to 32 bits, which means0xffffffffmeans-1. yes really, that's the whole bit-truncation situation, no cap π
and the big one, the rule that matters:
π it's only valid to call this when task is known to be blocked. not guessing. not hoping. known. periodt π
π SEE ALSO π
- Kernel file
./include/asm-generic/syscall.h syscall_set_nr(9)syscall_rollback(9)syscall_get_error(9)syscall_get_return_value(9)syscall_set_return_value(9)syscall_get_arguments(9)syscall_set_arguments(9)syscall_get_arch(9)
that's the whole page bestie, go read the whole syscall family, they're all iconic together π§π
β from ./include/asm-generic, dated October 2026, 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