From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 711033864C65 for ; Thu, 11 Jan 2024 18:23:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 711033864C65 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 711033864C65 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704997406; cv=none; b=xd3Orb9tdQ0GI2xkMQKo2OHN5GzbQNn8Gphd4VqgCy+TTAVEB4tFrGon3NkdrWnmLJTHGN1pMlzcdqHq53/wlNhwqpmKJuswtEm5j+x8zGFbQiAzKpV2WWCNk6evTC4qyBmAdPMU+B2/4D22f3+m9Z9T1lBvyv9hQHG726ssh/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704997406; c=relaxed/simple; bh=WHClsspnJOtdEjZRZaBnFP96wl3+8X1zl4080jmnBwk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=VaUJvCHPax1twPyZZz9j+zU/fwTNQ5FSjIMGJrmhnRbrcT76YzqSHyZ5gssavqIr2c0SP4IvDTH7YeJv9F/9tV2F8xu5cKhtFlD/21j+DnAW5laHoh4EglgOnxu/YSUW4z/vcdgLmEeDmU/3Xj0E6ootJDDsLcR5XTmrQgFyfM8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704997403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D32InGmoHWTVWleZTdsZ/cqaQtF3p8Fvb90HnPG+8ak=; b=OsvmSUJPVIiS+I58qz/x5RKGZxlgfSEg+pB8mQDwSJvFNEWhY1CcsLF7rndjagJyA25T1b PgBgUfgk9frEPHhEAW0m2YWRKuymIkZL67yrDxHqGDk6+9sLjSwrKnuecnXzmYh26vrv8e QYLaJD/a2L6o7pQ+RhDzCCg6aAcnzn8= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-YmSMdEvbNYKp5mm5mTiNiQ-1; Thu, 11 Jan 2024 13:23:22 -0500 X-MC-Unique: YmSMdEvbNYKp5mm5mTiNiQ-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-429a1b96ad2so60305401cf.0 for ; Thu, 11 Jan 2024 10:23:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704997401; x=1705602201; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D32InGmoHWTVWleZTdsZ/cqaQtF3p8Fvb90HnPG+8ak=; b=jPvqIDEWibh2hllFuZjh1PoA53T66uFFJspZIgW5YCTCx1yHEfxSE+OX8SZq1Cosd4 /TZxFSlel5MklEaIyHS44eklOfGe2Ga4zntrsnhkLR8fJHcTOPQghPiPC3rzPsYUQ88X A/GenezpxHP6t+YfWXxiB6sNEKbBw7Hdjs4DSAgvZHj8axyvSdai7k7OHnltNvr1LOJr DMIBZAYkMU4pDmgXBZ0jsLW5xuUNoQ09HGQYrZpshGprd5Z6Vv5qOZyEzxq1nqWW/wRz oQXuUCxkVJeJ6lxZey+V95LdG5dKb5JdPsqK0hLwo0N+QoOa/PWdjqr4kV1LTnY2ky0i 3kyQ== X-Gm-Message-State: AOJu0Yx2UojkoXmK3bd6jGfWkOGItUWQrXAjR1rESbHDvm0/zJlCVEwG zgIRqd8Dcl3prhVOL1pJci1LK+/77YngpYo9SSq3crtF45Vj3+Whvdh8W7UAsvJM/XOApTwiHnX 67VuwODYWHXWN/qXBMrY8s5ymTMzLc1d34CU= X-Received: by 2002:ac8:5409:0:b0:429:c6e3:6bd9 with SMTP id b9-20020ac85409000000b00429c6e36bd9mr1209258qtq.15.1704997401440; Thu, 11 Jan 2024 10:23:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEclVLue6E7tMYxsz4aMDMBt04ggzKOZRbPJHhbOBrgCWFlp08REtSuGUnJxpcGeKBSMboncQ== X-Received: by 2002:ac8:5409:0:b0:429:c6e3:6bd9 with SMTP id b9-20020ac85409000000b00429c6e36bd9mr1209247qtq.15.1704997401204; Thu, 11 Jan 2024 10:23:21 -0800 (PST) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id bb29-20020a05622a1b1d00b00429c97d8296sm262319qtb.60.2024.01.11.10.23.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Jan 2024 10:23:20 -0800 (PST) Message-ID: <4f03eba5-2ddc-1178-9ca1-d50614e9e441@redhat.com> Date: Thu, 11 Jan 2024 13:23:19 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: RFC: A way to get a TID from a pthread_t handler To: Trevor Gross , libc-help@sourceware.org Cc: jistone@redhat.com References: From: Carlos O'Donell Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: On 1/11/24 01:10, Trevor Gross via Libc-help wrote: > 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. This is much more complicated than it seems at first :-) Please read through: Bug 27880 - Please provide a pthread pid accessor https://sourceware.org/bugzilla/show_bug.cgi?id=27880 Discussion here: https://inbox.sourceware.org/libc-alpha/6d79a213-0df2-be8e-3596-e010f366a34f@linaro.org/ I don't recommend this as a "first contribution" kind of patch. Are you looking to start with libc development? Are you looking for an initial project to work on? -- Cheers, Carlos.