i) sysctl - Not avaiable in kernel.
Following code works in userland
int mib[3], argmax, nargs, c = 0;
mib[0] = CTL_KERN;
mib[1] = KERN_PROCARGS2;
mib[2] = pid; --> pid of process pid_t
size = (size_t)argmax;
if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1) {
}
ii) sysctlbyname - Tried something like following but unable to make it work. 1122 is 'pid' here. Tried to convert mib structure to an equivalent 'string'.
Sysctlbyname(“kern.proc.pid.1122”, &kinfo_proc, &len, NULL, 0);
Sysctlbyname(“kern.procargs2.1122”, &kinfo_proc, &len, NULL, 0) ;
iii) Tried "fd_ofiles" (available in proc structure but getting kernel panic while accessing it)
iv) p_textvp - It's avaialble in proc structure but it's always NULL.
v) kvm_getprocargs is not avaialble (libkvm is not available) - discontinued from TIGER.
Regards,
~Charu