C program to get pid of process
grx0736 at uoft02.utoledo.edu
grx0736 at uoft02.utoledo.edu
Sat Apr 27 08:25:15 AEST 1991
this follows my earlier mail regarding pid of
running processes. I have tried writing a small
program which looks somthing like :
main(argc, argv)
int argc;
char **argv;
{
kvm_t *kd;
struct proc *myproc;
struct user *u;
char ***arg;
char ***env;
int cmd_return;
int mypid;
scanf("%d", &mypid);
kd = kvm_open(NULL, NULL, NULL, O_RDONLY, argv[0]);
while(1) {
myproc = kvm_nextproc(kd);
if(myproc->p_pid == mypid)
printf("your process found\n");
u = kvm_getu(kd, myproc);
cmd_return = kvm_getcmd(kd, myproc, u, arg, env);
}
}
the program gets the proc structures corresponding
to all the processes, but when i call kvm_getcmd, nothing
is being assigned to arg .
Sun manuals say that after the call arg will point
to the command infomation of the process corresponding to
myproc. however, when i run this program, arg and env always
point to nil. but the call to kvm_getcmd returns 0 (zero)
indicating that the call was successful.
any help in the above matter would be highly appreciated.
sunil kulkarni
More information about the Comp.unix.internals
mailing list