Updated with Tizen:Base source codes
[external/procps.git] / packaging / procps-3.2.7-longcmd.patch
1 --- procps-3.2.7/proc/readproc.c.kzak   2006-06-16 10:18:13.000000000 +0200
2 +++ procps-3.2.7/proc/readproc.c        2006-09-27 11:25:13.000000000 +0200
3 @@ -432,14 +432,17 @@
4      if(fd==-1) return NULL;
5  
6      /* read whole file into a memory buffer, allocating as we go */
7 -    while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
8 +    while ((n = read(fd, buf, sizeof buf - 1)) >= 0) {
9         if (n < (int)(sizeof buf - 1))
10             end_of_file = 1;
11 -       if (n == 0 && rbuf == 0)
12 +       if (n == 0 && rbuf == 0) {
13 +           close(fd);
14             return NULL;        /* process died between our open and read */
15 +       }
16         if (n < 0) {
17             if (rbuf)
18                 free(rbuf);
19 +           close(fd);
20             return NULL;        /* read error */
21         }
22         if (end_of_file && buf[n-1])            /* last read char not null */