22 lines
738 B
Diff
22 lines
738 B
Diff
--- procps-3.2.7/proc/readproc.c.kzak 2006-06-16 10:18:13.000000000 +0200
|
|
+++ procps-3.2.7/proc/readproc.c 2006-09-27 11:25:13.000000000 +0200
|
|
@@ -432,14 +432,17 @@
|
|
if(fd==-1) return NULL;
|
|
|
|
/* read whole file into a memory buffer, allocating as we go */
|
|
- while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
|
|
+ while ((n = read(fd, buf, sizeof buf - 1)) >= 0) {
|
|
if (n < (int)(sizeof buf - 1))
|
|
end_of_file = 1;
|
|
- if (n == 0 && rbuf == 0)
|
|
+ if (n == 0 && rbuf == 0) {
|
|
+ close(fd);
|
|
return NULL; /* process died between our open and read */
|
|
+ }
|
|
if (n < 0) {
|
|
if (rbuf)
|
|
free(rbuf);
|
|
+ close(fd);
|
|
return NULL; /* read error */
|
|
}
|
|
if (end_of_file && buf[n-1]) /* last read char not null */
|