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
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to