sys_tgkill(9)
π sys_tgkill(9) β like, the thread-targeted signal syscall, bestie π
okay so this is a page from the Kernel API Manual, and it's all about sys_tgkill β the syscall that slides into one specific thread's DMs with a signal π―β¨
πΈ NAME πΈ
sys_tgkill β send a signal to one specific thread, not the whole group, no cap π
β¨ SYNOPSIS β¨
long sys_tgkill (pid_t tgid , pid_t pid , int sig );
literally three args, that's it, that's the whole vibe π«Ά
π ARGUMENTS π
tgidβ the thread group ID of the thread π (yes it wants the group too, we'll get to why)pidβ the PID of the thread π¦ the specific one, the main charactersigβ the signal to be sent π₯ the actual message
π DESCRIPTION π
so here's the iconic part: this syscall also checks the tgid, and it returns -ESRCH even if the PID exists β but that PID isn't belonging to the target process anymore. π
and likeβ¦ that's not a bug, that's the whole point. it solves the problem of threads exiting and PIDs getting reused. because bestie, PIDs get recycled constantly and if you weren't double-checking you'd be out here firing signals at some totally random new process that just happened to inherit the number ππ
no cap, the tgid check is the safety rail here. it's giving "confirm before you send" energy and honestly? we stan a defensive syscall π§
π¦ SEE ALSO π¦
the kernel file ./kernel/signal.c β go read it, it's where all of this lives π
and then the whole friend group, in the order the original rolls with:
task_set_jobctl_pending(9)task_clear_jobctl_trapping(9)task_clear_jobctl_pending(9)task_participate_group_stop(9)ptrace_trap_notify(9)force_sig_seccomp(9)do_notify_parent_cldstop(9)do_signal_stop(9)do_jobctl_trap(9)do_freezer_trap(9)signal_delivered(9)sys_restart_syscall(9)set_current_blocked(9)sys_rt_sigprocmask(9)sys_rt_sigpending(9)copy_siginfo_to_external32(9)do_sigtimedwait(9)sys_rt_sigtimedwait(9)sys_kill(9)sys_pidfd_send_signal(9)sys_tkill(9)sys_rt_sigqueueinfo(9)sys_sigpending(9)sys_sigprocmask(9)sys_rt_sigaction(9)sys_rt_sigsuspend(9)
like, that's the whole signal-handling squad right there, iykyk πβ
aaaaand that's the page!! π this one's from ./kernel, dated October 2026, and it's sys_tgkill(9) β mwah, go send a signal to exactly one thread and be normal about it ππ
π
π¦ 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