blob: 7c4fdca360d306d797cf03b35ce2e63af31b5a2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
--- 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 */
|