Subject: lib/505: libkvm man pages are out of sync
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: None <martin@euterpe.owl.de>
List: netbsd-bugs
Date: 10/02/1994 10:20:04
>Number: 505
>Category: lib
>Synopsis: at least kvm_getarg doesn't work like its manual suggests
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: gnats-admin (Library Bug People)
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Sun Oct 2 10:20:03 1994
>Originator: Martin Husemann
>Organization:
private
>Release: current from a sup Sep 18
>Environment:
System: NetBSD euterpe.owl.de 1.0_BETA NetBSD 1.0_BETA (EUTERPE) #0: Fri Sep 30 16:36:34 MET 1994 root@euterpe.owl.de:/usr/src/sys/arch/i386/compile/EUTERPE i386
>Description:
I tried to write a program to get a process command line (like
ps -wwp <pid>). After a look in the manuals I came up with this:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <kvm.h>
#include <sys/kinfo.h>
#include <sys/kinfo_proc.h>
char * getcmd(pid_t pid)
{
static char buffer[8092];
char **erg, *q, *d;
struct kinfo_proc *p;
int cnt;
kvm_t *kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "getcmd");
p = kvm_getprocs(kd, KINFO_PROC_PID, pid, &cnt);
erg = kvm_getargv(kd, p, sizeof buffer);
kvm_close(kd);
/* now we have somthing like char **argv, turn it into a simple
* commandline (ignoring any neseccary quoting for now)
*/
for (d = buffer; *erg; erg++) {
q = *erg;
while(*q) {
*d++ = *q++;
}
*q++ = ' ';
}
*--q = '\0';
return buffer;
}
>How-To-Repeat:
Try to compile above code / read man kvm_getargv
>Fix:
>Audit-Trail:
>Unformatted: