From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 25 20:41:07 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0204837C; Fri, 25 Jan 2013 20:41:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id D1A6F81B; Fri, 25 Jan 2013 20:41:06 +0000 (UTC) Received: from pakbsde14.localnet (unknown [38.105.238.108]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 345D5B93E; Fri, 25 Jan 2013 15:41:03 -0500 (EST) From: John Baldwin To: "Robert N. M. Watson" Subject: Re: libprocstat(3): retrieve process command line args and environment Date: Fri, 25 Jan 2013 15:31:43 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p22; KDE/4.5.5; amd64; ; ) References: <20130119151253.GB88025@gmail.com> <201301241120.52054.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201301251531.43540.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 25 Jan 2013 15:41:03 -0500 (EST) Cc: Mikolaj Golub , Stanislav Sedov , freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2013 20:41:07 -0000 On Friday, January 25, 2013 1:37:45 pm Robert N. M. Watson wrote: > > On 24 Jan 2013, at 16:20, John Baldwin wrote: > > >>> Hmm, are you going to rewrite ps(1) to use libprocstat? Or rather, is that a > >>> goal someday? That is one current consumer of kvm_getargv/envv. That might > >>> be fine if we want to make more tools use libprocstat instead of using libkvm > >>> directly. > >> > >> I didn't have any plans for ps(1) :-) That is why I wrote about "new > >> code". But if you think it is good to do I might look at it one day... > > > > I'm mostly hoping Robert chimes in to see if that was his intention for > > libprocstat. :) If we can ultimately replace all uses of kvm_get*v() with > > calls to procstat_get*v*() then I'm fine with some code duplication in the > > interim. > > > Originally there was just proctstat(1), but it made sense to begin re- encapsulating it in a libprocstat(3) because the code there is potentially extremely reusable. This conflicts a bit with libkvm(3), which mysteriously knows about sysctlbyname(3) despite a name suggesting otherwise. You can imagine various approaches to fixing this, but indeed, making libprocstat(3) the first-class citizen and preferring it for both kvm and sysctl methods sounds like the way to go. I actually want to make libprocstat also support snmp, but I've never actually found the time to investigate doing that. One of my main unmet goals for procstat(1) was to introduce an extremely machine- readable output format for it -- e.g., something XML-based or similar. I'd still love to see that happen. BTW, one off-ball thought I have is that I would like to have a mode where libprocstat operates on a core file (of a process, not a kernel crash dump), so it could list the threads from a core dump, and possibly file descriptor info (if PR kern/173723 is implemented). We certainly could have a 'raw' mode where it spat out name: value or XML of the entire kinfo_proc perhaps. -- John Baldwin