On Tuesday, January 22, 2013 4:17:43 pm Mikolaj Golub wrote:
> 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.

Well, you could make procstat open a kvm handle in both cases (open a "live" 
handle in the procstat_open_sysctl() case).  It just seems rather silly to be 
duplicating code in the two interfaces.  More a question for Robert: does 
libprocstat intentionally duplicate the code in libkvm for other things as 
well in the live case?  (Like fetching the list of processes?)

-- 
John Baldwin
_______________________________________________
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