libprocstat(3): retrieve process command line args and environment

Mikolaj Golub trociny at FreeBSD.org
Sat Mar 16 22:57:05 UTC 2013


On Sun, Mar 17, 2013 at 12:35:20AM +0200, Mikolaj Golub wrote:

> Ah, this is a thing I wanted to discuss but forgot! As I understand
> the idea of the 'ABI hack' is: if the output buffer is less than the
> size of data we have, truncate our data to the last successfully
> written kinfo_file structure and return without error.
> 
> In my code I do reset ENOMEM to 0 (see sysctl_kern_proc_filedesc), but
> I don't see a way how using sbuf interface I can truncate req->oldidx
> to the last successfully written file: sbuf_bcat() (to internal
> buffer) may be successful and the error might appear only later, when
> draining. I suspect it will break things if I return with a partial
> kinfo_file, but haven't come with a solution yet...

A solution I am going to try is to provide maxlen argument to
kern_proc_filedesc_out(), and if it is not 0, output files that do not
exceed the limit, so sysctl_kern_proc_filedesc would call:

  kern_proc_filedesc_out(p, &sb, req->oldlen);

-- 
Mikolaj Golub


More information about the freebsd-hackers mailing list