THR_EXIT(2)
π THR_EXIT π
okay bestie, so this one is from the System Calls Manual section β it's thr_exit, and it's giving "terminate current thread" energy. let's get into it π¦
β¨ NAME β¨
thr_exit β terminate current thread π
π LIBRARY π
Standard C Library β that's libc, linked with -lc. yep, she's a libc girlie π
πΈ SYNOPSIS πΈ
#include <sys/thr.h>
void
thr_exit(long *state);
π«Ά DESCRIPTION π«Ά
okay so real talk: this function is literally intended for implementing threading. if you're just a normal application doing normal application things, you should be calling pthread_exit(3) instead. no cap. thr_exit is the low-level machinery, not the vibe you want to be messing with unless you're literally building a threading library π
The thr_exit() system call terminates the current kernel-scheduled thread. periodt.
Now, if the state argument is not NULL, the location that the argument points to gets updated with an arbitrary non-zero value, and an _umtx_op(2) UMTX_OP_WAKE operation is consequently performed on that location. (yes bestie, arbitrary β don't go assuming it's your thread id or anything cute like that, it's just... a non-zero value. it is what it is π)
β οΈ big warning energy: attempts to terminate the last thread in the process are silently ignored. like, no error, no nothing, just vibes and a shrug. if you actually want the process gone-gone, use the _exit(2) syscall to terminate the process. that's the move π
β RETURN VALUES β
The function does not return a value. that's the whole point, she exits.
but lowkey, if you do see a return from this function? that means the calling thread was the last one in the process. so like... if you get a return, that's your sign. main character moment, but also kind of a jumpscare π
π SEE ALSO π
_exit(2)thr_kill(2)thr_kill2(2)thr_new(2)thr_self(2)thr_set_name(2)_umtx_op(2)pthread_exit(3)
π STANDARDS π
The thr_exit() system call is non-standard β she's not in any official spec, she's just doing her own thing. she's used by the 1:1 Threading Library (libthr, -lthr) to implement the IEEE Std 1003.1-2001 (βPOSIX.1β) pthread(3) functionality. so like, the posix girlies are standing on her shoulders, iykyk π
and that's the whole page bestie!! this one shipped from Debian on June 1, 2016 β yeah she's an oldie but a goodie, and she's still out here holding up your threads. slay, queen. go call pthread_exit(3) like a normal person tho πβ¨π¦π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2016 The FreeBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms