THR_SELF(2)
π THR_SELF π
okay so bestie, welcome to the thr_self(2) page, aka the "who even am I" syscall, and honestly? it's giving self-discovery era πΈ. this one lives in the System Calls Manual, and it's here to hand you the thread identifier of the calling thread. no cap.
β¨ LIBRARY β¨
Standard C Library (libc, -lc) π«Ά
π SYNOPSIS π
#include <sys/thr.h>
int
thr_self(long *id);
π DESCRIPTION π
so here's the tea β: the thr_self() system call stores the system-wide thread identifier for the current kernel-scheduled thread into the variable that the argument id points at. that's it. that's the whole vibe. she's simple, she's iconic π
.
now, the thread identifier itself? it's an integer, and it lives in the range from PID_MAX + 2 (10002) all the way up to INT_MAX. yes, that's the whole neighborhood ποΈ.
and listen β the thread identifier is guaranteed to be unique at any given time, for each running thread in the system. so no two threads are out here sharing an ID at the same moment. periodt. β¨
but bestie, heads up π: after the thread exits, the identifier may be reused. so don't go treating it like a forever tattoo, okay? it's more of a temporary situationship π.
π RETURN VALUES π
if everything slays, thr_self() returns zero π₯³. otherwise it hands you back -1, and errno gets set to tell you what went wrong. she's dramatic like that.
π ERRORS π
the thr_self() operation may return the following errors:
[EFAULT]β the memory that theidargument points to is not valid π. like, girl, that pointer is not it.
π¦ SEE ALSO π¦
thr_exit(2)thr_kill(2)thr_kill2(2)thr_new(2)thr_set_name(2)_umtx_op(2)pthread_getthreadid_np(3)pthread_self(3)
go read those too, iykyk π
β STANDARDS β
real talk: the thr_self() system call is non-standard, bestie. she doesn't play by the ISO rules, she makes her own π. she's used by the 1:1 Threading Library (libthr, -lthr) to implement IEEE Std 1003.1-2001 (βPOSIX.1β) pthread(3) functionality. so like, she's the backstage crew making the main character shine β¨.
and that's the whole page, babe π«Ά this came to you courtesy of Debian, dated June 1, 2016 β so yeah, she's been iconic for a minute. stay unique (at any given time) and don't get recycled ππΈπ¦
π¦ 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