public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hpa at zytor dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug nptl/27880] New: Please provide a pthread pid accessor Date: Tue, 18 May 2021 01:19:51 +0000 [thread overview] Message-ID: <bug-27880-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=27880 Bug ID: 27880 Summary: Please provide a pthread pid accessor Product: glibc Version: unspecified Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: nptl Assignee: unassigned at sourceware dot org Reporter: hpa at zytor dot com CC: drepper.fsp at gmail dot com Target Milestone: --- There is currently no way to access the kernel tid for another pthread, except via the very cumbersome thread_db interface. The intent is good, to provide interface isolation, but sometimes having such cross-layer interfaces (e.g. fileno()) are at the very least serve a "harm reduction" function. As it is, there are enough reasons access to a tid is necessary that programmers are employing multiple unsafe techniques: 1. Calling gettid() early in the thread main function and caching that value indefinitely; 2. Mixing pthreads and raw calls to clone(); 3. Extracting or even hard-coding the offset for tid in struct pthread (almost never using any kind of hard version tying.) Having an interface like: pid_t pthread_gettid_np(pthread_t thread) ... would at least allow the interface to be kept in sync with the current libpthread, and provides a path to returning an error if no meaningful tid is available (e.g. in the case of M:N threads, or the underlying kernel thread no longer existing.) -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2021-05-18 1:19 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-18 1:19 hpa at zytor dot com [this message] 2021-05-18 5:05 ` [Bug nptl/27880] " hpa at zytor dot com 2021-05-18 18:36 ` joseph at codesourcery dot com 2021-05-18 19:31 ` hpa at zytor dot com 2021-05-18 20:58 ` adhemerval.zanella at linaro dot org 2021-05-19 20:14 ` fweimer at redhat dot com 2021-05-19 20:21 ` hpa at zytor dot com 2021-05-19 20:27 ` adhemerval.zanella at linaro dot org 2021-05-19 20:31 ` hpa at zytor dot com 2021-05-19 20:49 ` fweimer at redhat dot com 2021-05-19 22:50 ` mtk.manpages at gmail dot com 2021-05-27 19:32 ` adhemerval.zanella at linaro dot org 2021-05-27 23:48 ` hpa at zytor dot com 2023-04-14 3:50 ` sam at gentoo dot org 2024-02-06 22:30 ` jkriegshauser at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-27880-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).