ptrace_init_task(9)
π« ptrace_init_task β like, the Kernel API Manual page, bestie β¨
Okay so this is ptrace_init_task(9) from the Kernel API Manual, and honestly? It's giving "small function, big responsibilities" π Stick with me and you'll have it down fr fr.
πΈ NAME πΈ
ptrace_init_task β sets up the ptrace state for a brand-new child task, no cap π
β¨ SYNOPSIS β¨
void ptrace_init_task (struct task_struct *child , bool ptrace );
π¦ ARGUMENTS π¦
childβ the new child task in question, the little main character πΆptraceβ abool, and it'strueif the child should be ptrace'd by the parent's tracer π
π DESCRIPTION π
So here's the vibe: this gets called immediately after child has been added to its parent's children list. Like, right after. Not before, not later. Timing is everything, bestie β°
About that ptrace flag β false is the normal, everyday case, and true means "yep, ptrace this child." That's the whole deal π€·ββοΈ
π¨ Locking lore, pay attention: this is called withcurrent's siglock andwrite_lock_irq(tasklist_lock)held. Both of them. Simultaneously. Do not come in here unlocked, that's not the move ππ
π₯ SEE ALSO π₯
Kernel file ./include/linux/ptrace.h, plus the whole friend group:
ptrace_may_access(9)ptrace_parent(9)ptrace_event_enabled(9)ptrace_event(9)ptrace_event_pid(9)ptrace_release_task(9)arch_has_single_step(9)user_enable_single_step(9)user_disable_single_step(9)arch_has_block_step(9)user_enable_block_step(9)arch_ptrace_stop_needed(9)arch_ptrace_stop(9)ptrace_report_syscall_permit_entry(9)ptrace_report_syscall_exit(9)
And that's the whole page, periodt π«Ά This little gem lives in ./include/linux, dated October 2026 β go tell your friends, iykyk πβ¨
π¦ 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