From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by sourceware.org (Postfix) with ESMTPS id 7A9B03858D38 for ; Thu, 11 Jan 2024 06:10:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A9B03858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=umich.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=umich.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A9B03858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704953431; cv=none; b=P4+mHwVKPHscHi4GizRA8R3P0Z1qqts2Age/HlSy3qSRviGImh/oQVnfsNuC7qLfp6/iNHFucx418F/E3PLfNx4ICzUXYJrVcOCHpjQckHYVv1xKbhvtZDZGmX4cMQCtiIDGPL5RA2kYo/jmFqmJWefbpFlkQDZWbKbGaYXiwCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704953431; c=relaxed/simple; bh=qvGou/KJW3/Z8c6c8AXHXu30aq66NRyAArwMWBM65L0=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=PrujXjOqCbNR1niKgtRqBaoe7gZjesvI5R7qB0h8Hm6Y19YR/RFue5gdWnIBs5QO5w+q/ISqcDhmp6aQReAvzrvcM1tk376bEgZahsRt2GKp04CVzjvrhcxML/sfFWJbxbspBYxbbRbmjihDGwJn+qBdFS/x64uXxlLkW7cnpZU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-5f68e2e1749so42272607b3.2 for ; Wed, 10 Jan 2024 22:10:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; t=1704953429; x=1705558229; darn=sourceware.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=m91MQ4cHQIddwqQYie6IFJkBx4lazPWahPfta/luark=; b=HlKQFy/dl0h0LQiqWeW+uUniVBiYZw+aXPJ2g5GijOeXoG8+L9me91k5nRQM+1FQ1I L2k9ZevqbPD4O/9vd3TTv63pbA5ZhME6OpuSNEV1jz02gOMBZe9KicI5aN2bXjOfHWlI am3s5UyOebbNBbPLBnzUpO2h1BygqPOt98ddlfHPIQD0t85R8NbAVtaUM34MPjywT8FB gj7hQPzeKqO4soMW88SZ0BZ51kn9kGq2rlurny+xxm3tYVSP6c+Djibzi6egyau82tzB 1Zr9s0v6J5FL7tZo4kX2LxSD7fKpL7gUOjgcheX+nuxf7x7vPA79gwvdi9fUR2eWpkNl vj0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704953429; x=1705558229; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=m91MQ4cHQIddwqQYie6IFJkBx4lazPWahPfta/luark=; b=v7vlUYEXWghnDJ2h9jPZydYGrkkyby4t7X0N/F4W6uXAVu47k/MN7F+zgBUjE/kQkO ZkanE9YqUGZv+4S0KZVTbjnKNqxgZRsmPuAqr+Ef5ullGRiZj8wZzJ/S2dr/DUUXv1mY afIPojDcGBBmKMOiBtr4vKvCO6V1kE1IBEb2nKWOqjCzLM4ZSpG8ApJKIfJaxkggNwGI 0jmJEoTE4L7zWXx2y1Jzcd1cMTngM5UZEXCEn1tcdsd/2tMuy5Zm3iHip72/hjk3eukP AnRAZMbqBogjcP4ZIz7SBjMtfXgWhes+RxylqoMXyOtQA7hdcJvxV6Xa7lkUCPOvtn3L LZ7g== X-Gm-Message-State: AOJu0Yyr7rPtHzY87qhBG+xezJNKVFdpDQMfGfEiIEX/ANGX+4XYWMel IDwY+bMK/hs/jZgoROQ8NFMzwcaSfqbgCnOMlfkJ7hmSjjybnan76JcO9ujo X-Google-Smtp-Source: AGHT+IFEX2S8UWOCR1CJD2zDJGp4awkBtujESnkn5ML9yQ78YYYMaji5gwPhARM0CDGGmBqfXByoOuPfVCgGMJwyo1s= X-Received: by 2002:a81:ca47:0:b0:5ea:3c8d:40e6 with SMTP id y7-20020a81ca47000000b005ea3c8d40e6mr105471ywk.14.1704953429377; Wed, 10 Jan 2024 22:10:29 -0800 (PST) MIME-Version: 1.0 From: Trevor Gross Date: Thu, 11 Jan 2024 01:10:18 -0500 Message-ID: Subject: RFC: A way to get a TID from a pthread_t handler To: libc-help@sourceware.org Cc: jistone@redhat.com, "carlos@systemhalted.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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