THR_KILL(2)
π THR_KILL(2) β like, the thread-signalling girlies π
okay bestie, welcome to THR_KILL(2), the System Calls Manual page where we learn how to slide a signal into one specific thread instead of dumping it on the whole entire process. iykyk. π
β¨ NAME β¨
thr_kill β send signal to thread π―
π«Ά LIBRARY π«Ά
Standard C Library (libc, -lc) β she's built in, no extra shopping required. π
πΈ SYNOPSIS πΈ
#include <sys/thr.h>
int
thr_kill(long id, int sig);
int
thr_kill2(pid_t pid, long id, int sig);
π¦ DESCRIPTION π¦
so the thr_kill() and thr_kill2() system calls let you send a signal β the one you specify with the sig argument β to some threads in a process. not all of them. some. targeted. main character selectivity. β¨
quick vibe check on who's allowed to get signalled:
- with
thr_kill(), the signalled threads are always limited to the current process. she stays home. no wandering. π - with
thr_kill2(), thepidargument specifies the process whose threads you wanna signal. so you can go visit. π
now, the id argument is the whole "which thread tho" situation:
- if
idis equal to-1, all threads in the specified process are signalled β it's giving group chat blast π’ - otherwise, only the thread with the thread identifier equal to the argument is signalled β it's giving DM π
and the sig argument defines the delivered signal. it must be a valid signal number or zero. yes, zero is a real option, and here's the tea: in that case no signal is actually sent, and the call is used to verify the liveness of the thread. basically a "u up?" text. ππ«Ά
one more detail, don't skip it: the signal is delivered with siginfo si_code set to SI_LWP. π
π RETURN VALUES π
if successful, thr_kill() and thr_kill2() will return zero. otherwise -1 is returned, and errno is set to indicate the error. slay when it works, π when it doesn't.
π₯ ERRORS π₯
the thr_kill() and thr_kill2() operations return the following errors:
[EINVAL]β thesigargument is not zero and does not specify a valid signal. π«[ESRCH]β the specified process or thread was not found. she's not here, babe. π
additionally, the thr_kill2() may return the following errors:
[EPERM]β the current process does not have sufficient privilege to check existence or send a signal to the specified process. π nope, not allowed, no cap.
π SEE ALSO π
_umtx_op(2), kill(2), thr_exit(2), thr_new(2), thr_self(2), thr_set_name(2), pthread_kill(3), signal(3)
the whole friend group fr fr π«
π STANDARDS π
the thr_kill() and thr_kill2() system calls are non-standard β they're built diff, they don't follow the crowd π
β and are used by the 1:1 Threading Library (libthr, -lthr) to implement IEEE Std 1003.1-2001 ("POSIX.1") pthread(3) functionality. iconic behaviour, honestly. β
β HISTORY β
the thr_kill() and thr_kill2() system calls first appeared in FreeBSD 5.2. she's been around. vintage. π
ngl bestie,sigof zero is genuinely useful β it's the liveness check β but don't go thinking you can send just any number in there,EINVALwill humble you real quick. π
that's the whole page!! mwah π this was THR_KILL(2) from Debian, dated May 5, 2020 β go be iconic with your threads, ily, bye π§ββοΈπ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2016 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms