public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* RFC: A way to get a TID from a pthread_t handler
@ 2024-01-11  6:10 Trevor Gross
  2024-01-11 18:23 ` Carlos O'Donell
  2024-01-11 21:32 ` Florian Weimer
  0 siblings, 2 replies; 7+ messages in thread
From: Trevor Gross @ 2024-01-11  6:10 UTC (permalink / raw)
  To: libc-help; +Cc: jistone, carlos

Hello,

It seems like there isn't a good way to get the thread ID from a
pthread_t. If you are within the thread then you can call gettid(),
but there is no public API to get a spawned thread's TID after calling
pthread_create().

This value is stored in the pthread, so a new public function could
just be a basic getter:

    pid_t pthread_gettid(pthread_t threadid)
    {
      struct pthread *pd = (struct pthread *) threadid;
      return pd->tid;
    }

Would an addition like this likely get accepted? Or is there anything
overlooked about an easier way to recover the spawned thread's TID?

I could submit a patch, but require instruction on where this should live.

Thanks,
Trevor Gross

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-01-15 19:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11  6:10 RFC: A way to get a TID from a pthread_t handler Trevor Gross
2024-01-11 18:23 ` Carlos O'Donell
2024-01-12  7:29   ` Trevor Gross
2024-01-11 21:32 ` Florian Weimer
2024-01-12  7:55   ` Trevor Gross
2024-01-15 19:47     ` Adhemerval Zanella Netto
2024-01-15 19:54       ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).