Date: Tue, 22 Jan 2013 23:17:43 +0200 From: Mikolaj Golub <trociny@FreeBSD.org> To: John Baldwin <jhb@freebsd.org> Cc: Stanislav Sedov <stas@freebsd.org>, freebsd-hackers@freebsd.org, Robert Watson <rwatson@freebsd.org> Subject: Re: libprocstat(3): retrieve process command line args and environment Message-ID: <20130122211743.GA4490@gmail.com> In-Reply-To: <201301221201.06290.jhb@freebsd.org> References: <20130119151253.GB88025@gmail.com> <201301221201.06290.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130122211743.GA4490>