From owner-freebsd-hackers@freebsd.org Wed Mar 30 11:44:19 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E5297AE3C66 for ; Wed, 30 Mar 2016 11:44:19 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [31.223.170.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AD5FA1EE3 for ; Wed, 30 Mar 2016 11:44:19 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from rack1.digiware.nl (unknown [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id A21C515340D; Wed, 30 Mar 2016 13:44:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.nl Received: from smtp.digiware.nl ([127.0.0.1]) by rack1.digiware.nl (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hlbwncJVqwof; Wed, 30 Mar 2016 13:44:00 +0200 (CEST) Received: from [192.168.101.107] (vpn.ecoracks.nl [31.223.170.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.digiware.nl (Postfix) with ESMTPSA id EF9A0153416; Wed, 30 Mar 2016 13:43:59 +0200 (CEST) Subject: Re: Getting a thread name To: Sergey Kandaurov References: <56FBAD69.908@digiware.nl> Cc: FreeBSD Hackers From: Willem Jan Withagen Message-ID: <56FBBC00.6000901@digiware.nl> Date: Wed, 30 Mar 2016 13:44:00 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2016 11:44:20 -0000 On 30-3-2016 13:35, Sergey Kandaurov wrote: > On 30 March 2016 at 13:41, Willem Jan Withagen wrote: >> Hi, >> >> pthread_np has a call: pthread_set_name(tid, str). >> >> Now I'm looking for a way of retrieving that name. But there is no: >> pthread_get_name() in the same set. >> >> But I see top actually displaying the threadnames. So can somebody give >> me a hint where to look? Other than going thru top... >> > > It's extracted either over kvm(3) or sysctl(3) interface depending on > your needs. Search for kvm_getprocs() and KERN_PROC respectively. > You can also use libprocstat(3) that is a wrapper. First 2 sounds rather convoluted.... I have a thread ID and want the string with the threadname back, as set by pthread_set_name(). Fortunately is the place where I need it atm. is in process wrapup. So performance is not a real issue. I'll check your hints, thanx, --WjW