pmap stack detection
This commit is contained in:
@ -971,3 +971,29 @@ proc_data_t *readproctab2(int(*want_proc)(proc_t *buf), int(*want_task)(proc_t *
|
||||
return pd;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_proc_stats - lookup a single tasks information and fill out a proc_t
|
||||
*
|
||||
* On failure, returns NULL. On success, returns 'p' and 'p' is a valid
|
||||
* and filled out proc_t structure.
|
||||
*/
|
||||
proc_t * get_proc_stats(pid_t pid, proc_t *p)
|
||||
{
|
||||
static char path[PATH_MAX], sbuf[1024];
|
||||
struct stat statbuf;
|
||||
|
||||
sprintf(path, "/proc/%d", pid);
|
||||
if (stat(path, &statbuf)) {
|
||||
perror("stat");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (file2str(path, "stat", sbuf, sizeof sbuf) >= 0)
|
||||
stat2proc(sbuf, p); /* parse /proc/#/stat */
|
||||
if (file2str(path, "statm", sbuf, sizeof sbuf) >= 0)
|
||||
statm2proc(sbuf, p); /* ignore statm errors here */
|
||||
if (file2str(path, "status", sbuf, sizeof sbuf) >= 0)
|
||||
status2proc(sbuf, p, 0 /*FIXME*/);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
Reference in New Issue
Block a user