Improved so that it doesn't stat(2) every /proc/<PID>/.
* proclist.c: (glibtop_get_proclist_s): Improved so that it doesn't stat(2) every /proc/<PID>/.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2005-12-12 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* proclist.c: (glibtop_get_proclist_s):
|
||||
|
||||
Improved so that it doesn't stat(2) every /proc/<PID>/.
|
||||
|
||||
2005-12-07 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* procmap.c: (glibtop_get_proc_map_s):
|
||||
|
@@ -82,18 +82,13 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
/* read every every entry in /proc */
|
||||
|
||||
while((entry = readdir (proc))) {
|
||||
char buffer [64]; /* enough to hold "/proc/%ld" */
|
||||
unsigned pid;
|
||||
char *end;
|
||||
|
||||
pid = strtoul(entry->d_name, &end, 0);
|
||||
if(*end != '\0') continue;
|
||||
|
||||
/* is it really a directory? */
|
||||
sprintf (buffer, "/proc/%u", pid);
|
||||
if (stat (buffer, &statb)) continue;
|
||||
if (!S_ISDIR (statb.st_mode)) continue;
|
||||
if (entry->d_type != DT_DIR)
|
||||
continue;
|
||||
|
||||
if (!(pid = strtoul(entry->d_name, NULL, 10)))
|
||||
continue;
|
||||
|
||||
switch (which & GLIBTOP_KERN_PROC_MASK) {
|
||||
case GLIBTOP_KERN_PROC_ALL:
|
||||
|
Reference in New Issue
Block a user