lkml.org 
[lkml]   [1999]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject2.2.0-pre8 & top
If /proc/*/statm is present but empty -- as happens with kflushd and kswapd
(is this the correct kernel behavior?) -- "top" reports wrong RSS and SIZE
values, and also leaks file descriptors. The appended procps patch appears
to cover up the problems.
-Paul <kimoto@lightlink.com>

--- procps-1.2.9/proc/readproc.c-orig Wed Jan 7 12:28:05 1998
+++ procps-1.2.9/proc/readproc.c Tue Jan 19 15:02:06 1999
@@ -114,7 +114,17 @@ int file2str(char *directory, char *what

sprintf(filename, "%s/%s", directory, what);
if ( (fd = open(filename, O_RDONLY, 0)) == -1 ) return -1;
+# if 0
if ( (num_read = read(fd, ret, cap - 1)) <= 0 ) return -1;
+# else
+ if ( (num_read = read(fd, ret, cap - 1)) <= 0 ) {
+ /* This error may be ignored,
+ * so let's courteously avoid leaking file descriptors.
+ */
+ close (fd);
+ return -1;
+ }
+# endif
ret[num_read] = 0;
close(fd);
return num_read;
@@ -257,6 +267,15 @@ next_proc: /* get next PID for consid
if (Do(FILLMEM)) { /* read, parse /proc/#/statm */
if ((file2str(path, "statm", sbuf, sizeof sbuf)) != -1 )
statm2proc(sbuf, p); /* ignore statm errors here */
+# if 0
+ /* nothing */
+# else
+ else
+ /* Is this right? At least it's sane. */
+ p->size = p->resident = p->share = p->trs =
+ p->lrs = p->drs = p->dt = 0.0;
+# endif
+
} /* statm fields just zero */

/* some number->text resolving which is time consuming */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.042 / U:1.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site