Bug 14300 - Add pid_t pthread_gettid_np(pthread_t *thr).
Summary: Add pid_t pthread_gettid_np(pthread_t *thr).
Status: RESOLVED DUPLICATE of bug 6399
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2012-06-27 06:46 UTC by Nicholas Miell
Modified: 2014-06-13 14:57 UTC (History)
3 users (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Miell 2012-06-27 06:46:07 UTC
fcntl(fd, F_SETOWN_EX, &((struct f_owner_ex) {F_OWNER_TID, tid})) needs some way of getting a thread's TID, and manually calling the gettid() syscall yourself is ugly.

There should probably be a way of converting a TID to a pthread_t, too.
Comment 1 Rich Felker 2012-06-27 13:02:46 UTC
Converting a TID to a pthread_t is highly non-trivial; there's no direct mapping possible. The best way I can think of is using one of the pthread-implementation-reserved signals to signal the TID and request it to call pthread_self and pass back the result.

Another option that would remove the need for the difficult-to-provide interface just for the sake of having an inverse function would be to forget pthread_gettid_np and just expose gettid (if it's not already exposed). I would say best practices would have a thread arranging for its own receipt of signals rather than having other threads set it up...

Anyway, shouldn't this report/request be marked as "enhancement" importance rather than "normal" or even "minor"? It doesn't seem like a bug.
Comment 2 Ondrej Bilka 2013-10-09 19:31:59 UTC

*** This bug has been marked as a duplicate of bug 6399 ***