[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Can someone wth llibkvm (e.g. Solaris) try this for me ?
From: |
Pete French |
Subject: |
Can someone wth llibkvm (e.g. Solaris) try this for me ? |
Date: |
Fri, 20 Jun 2003 16:26:41 +0100 |
Am working on a new NSProcessInfo for both FreeBSD and Solaris. If anyone
out there has such a machine can they try the following quick-and-dirty Code to
verify that the kvm calls are backward compatible from FreeBSD to SOlaris.
If anyone else has libkvm then could they try it too in fact...
cheers,
-bat.
PS: Should compile wth no warnings....
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <kvm.h>
#include <sys/param.h>
#include <sys/sysctl.h>
int
main(int argc, char *argv[])
{
kvm_t *k = NULL;
struct kinfo_proc *proc;
int n = 0;
char **argvv, **envv;
int i;
k = kvm_open(NULL, "/dev/null", NULL, O_RDONLY, "xyz");
if(!k) {
puts("CANT OPEN KERNEL");
return 0;
}
/* get the process */
proc = kvm_getprocs(k, KERN_PROC_PID, getpid(), &n);
if(!proc) {
puts("CANT GET PROCESS");
return 0;
}
if(n != 1) {
printf("n IS %d", n);
return 0;
}
/* get the environment */
envv = kvm_getenvv(k, proc, 0);
if(!envv) {
puts("CANT GET ENVIRONMENT");
return 0;
}
for(i=0;envv[i];i++) {
puts(envv[i]);
}
/* get the arguments */
argvv = kvm_getargv(k, proc, 0);
if(!argvv) {
puts("CANT GET ARGUMENTS");
return 0;
}
for(i=0;argvv[i];i++) {
puts(argvv[i]);
}
kvm_close(k);
return 0;
}
- Can someone wth llibkvm (e.g. Solaris) try this for me ?,
Pete French <=