THR_EXIT(2)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… THR_EXIT(2) β€” like, the thr_exit girlies' era

okay so real talk: this is from the System Calls Manual section 2, and it's literally the page for thr_exit, bestie. buckle up πŸŽ€

🌸 NAME

thr_exit β€” terminate current thread (yes, that's the whole gig. she ends threads. she's iconic like that ✨)

πŸ¦‹ LIBRARY

Standard C Library (libc, -lc) β€” that's where she lives, no cap πŸ’–

✨ SYNOPSIS

#include <sys/thr.h>

void
thr_exit(long *state);

look at her. tiny signature, big main character energy πŸ‘‘

πŸ’œ DESCRIPTION

okay so first thing first, bestie β€” this function is intended for implementing threading. normal applications should call pthread_exit(3) instead, fr fr. this one is for the plumbing, not for you to just vibe with πŸ™ˆ

The thr_exit() system call terminates the current kernel-scheduled thread. that's it. that's the tweet. πŸ’€

If the state argument is not NULL, then the location pointed to by the argument gets updated with an arbitrary non-zero value, and an _umtx_op(2) UMTX_OP_WAKE operation is consequently performed on the location. so like, you leave a little ✨non-zero✨ breadcrumb and then everyone waiting on that spot gets woken up. iconic behavior honestly 🫢

⚠️ Attempts to terminate the last thread in the process are silently ignored. like, she just doesn't. use the _exit(2) syscall to terminate the process instead β€” that's the actual move for ending the whole thing, bestie πŸ”₯

πŸ’€ RETURN VALUES

The function does not return a value. periodt.

A return from the function indicates that the calling thread was the last one in the process β€” so if you ever get a return back, that's not a success story, that's just you being the final survivor 😭 lowkey the plot of every apocalypse movie.

🌈 SEE ALSO

the whole friend group honestly πŸ’… iykyk

πŸ‘‘ STANDARDS

The thr_exit() system call is non-standard and is used by 1:1 Threading Library (libthr, -lthr) to implement IEEE Std 1003.1-2001 (β€œPOSIX.1”) pthread(3) functionality. so she's not part of the standard, she's the girl behind the girl 🧚

🌸 HISTORY

The thr_exit() system call first appeared in FreeBSD 5.2. a legend was born, no notes πŸ’–


and that's the whole page, bestie!! πŸŽ€ this little Debian build is dated May 5, 2020, and it's still serving THR_EXIT(2) realness to this very day β€” slay, honestly βœ¨πŸ¦‹πŸ‘‘

πŸ“¦ where this page comes from