Re: How to determime process name from pid?
19 Nov
2001
19 Nov
'01
5:43 p.m.
Based on reading ps sources: #include <sys/sysctl.h> int mib[4]; struct kinfo_proc p; int bufSize; mib[0]=CTL_KERN; mib[1]=KERN_PROC; mib[2]=KERN_PROC_PID; mib[3]=the_pid; bufSize=sizeof(p); error=sysctl(mib,4, &p, &bufSize, NULL, 0); if error is 0, the data you want is in p->ki_p->p_comm This is a non-privileged operation.
8754
Age (days ago)
8754
Last active (days ago)
0 comments
1 participants
participants (1)
-
Chaskiel M Grundman