From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 22 21:17:49 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 612CEC5; Tue, 22 Jan 2013 21:17:49 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx1.freebsd.org (Postfix) with ESMTP id 3535C3FC; Tue, 22 Jan 2013 21:17:47 +0000 (UTC) Received: by mail-lb0-f178.google.com with SMTP id n1so3155206lba.23 for ; Tue, 22 Jan 2013 13:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=ZWKmXY5te34djI3HqJfIxtH7Y7f5LY3sDZnbmdZY5f8=; b=pddXKAAkU1WWqBj848flMsMJ71r1p7q2QPS1A3GG+Dk6yDnXtxqnl07glJHWUk6mVH gc19Q/ocRS1oQdvGq9L8tSy29RlypfJhBpzGXOYQNdZQOgHibp6Nt9oEqmdO4CGUZHgP Kzn6BRMY/qsYktO46ONRneaoXiSYWTSz3vXmYfwhNFO+78QcQeZg3nhP5B/hF0QTEFJ5 uVHgIl160dzyqzOHziyYwjHiSZfYK0x9OqL5Ep3O2WAxn35FaK3I4WooOJCx/bN2QHXq epLEBmWhMhsdc+nC4BQXX0WVwhVkDntUJ4OHoChLE8e9pL1OZqlTZkIQbS5YUBiBRNvR yBcg== X-Received: by 10.152.109.210 with SMTP id hu18mr21532324lab.12.1358889467031; Tue, 22 Jan 2013 13:17:47 -0800 (PST) Received: from localhost ([178.150.115.244]) by mx.google.com with ESMTPS id n7sm7512827lbg.3.2013.01.22.13.17.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Jan 2013 13:17:46 -0800 (PST) Sender: Mikolaj Golub Date: Tue, 22 Jan 2013 23:17:43 +0200 From: Mikolaj Golub To: John Baldwin Subject: Re: libprocstat(3): retrieve process command line args and environment Message-ID: <20130122211743.GA4490@gmail.com> References: <20130119151253.GB88025@gmail.com> <201301221201.06290.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201301221201.06290.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Stanislav Sedov , freebsd-hackers@freebsd.org, Robert Watson 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: Tue, 22 Jan 2013 21:17:49 -0000 On Tue, Jan 22, 2013 at 12:01:06PM -0500, John Baldwin wrote: > How is this different from kvm_getargv()? It seems to be a direct copy. libprocstat(3) is a frontend for sysctl(3) and kvm(3) interfaces, so it is good to extend it to cover "getarg/env" functionality. Yes the functions look similar to kvm_getargv() but I couldn't implement them just as wrappers around kvm_getargv(): I would like to have libprocstat functions thread safe, while kvm_getargv() uses static variables for its internal buffers. It looks like I could fix kvm_getargv() to use fields of kvm structure instead of static variables to store pointers to the buffers, and then use it in libprocstat(3). Do you think it is worth doing? BTW, struct __kvm already contains some pointers, which looks like are unused currently: char **argv; /* (dynamic) storage for argv pointers */ int argc; /* length of above (not actual # present) */ char *argbuf; /* (dynamic) temporary storage */ But if I even had kvm_getargv() to behave as I wanted, there is still an issue with using it in libprocstat(): to get kvm structure you need to initialize procstat using procstat_open_kvm(). It is supposed to call procstat_open_kvm() when you want to read from kernel memory, while kvm_getargv() uses sysctl. So from a user point of you it would be a litle confusing if she had to call procstat_open_kvm() to get runtime args and env. If she wanted e.g. to get both runtime args and file info (via sysctl) she would have to do procstat_open_kvm() for args and procstat_open_sysctl() for files. -- Mikolaj Golub