Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1:Staging:C
procps
procps-ng-3.3.8-readeof.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File procps-ng-3.3.8-readeof.patch of Package procps
--- proc/readproc.c +++ proc/readproc.c 2013-05-29 10:55:48.129939330 +0000 @@ -544,7 +544,7 @@ static int file2str(const char *director if (ub->buf) ub->buf[0] = '\0'; else ub->buf = xcalloc((ub->siz = buffGRW)); sprintf(path, "%s/%s", directory, what); - if (-1 == (fd = open(path, O_RDONLY, 0))) return -1; + if (-1 == (fd = open(path, O_RDONLY, O_NOATIME))) return -1; while (0 < (num = read(fd, ub->buf + tot_read, ub->siz - tot_read))) { tot_read += num; if (tot_read < ub->siz) break; @@ -559,41 +559,42 @@ static int file2str(const char *director static char** file2strvec(const char* directory, const char* what) { char buf[2048]; /* read buf bytes at a time */ - char *p, *rbuf = 0, *endbuf, **q, **ret; - int fd, tot = 0, n, c, end_of_file = 0; - int align; + char *p, *rbuf = (char*)0, *endbuf, **q, **ret; + int fd, c; + ssize_t n, align, tot = 0; sprintf(buf, "%s/%s", directory, what); - fd = open(buf, O_RDONLY, 0); + fd = open(buf, O_RDONLY, O_NOATIME); 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) { - if (n < (int)(sizeof buf - 1)) - end_of_file = 1; - if (n == 0 && rbuf == 0) { - close(fd); - return NULL; /* process died between our open and read */ - } + do { + n = read(fd, buf, sizeof(buf) - 1); if (n < 0) { - if (rbuf) - free(rbuf); - close(fd); - return NULL; /* read error */ + tot = 0; + break; /* read error! */ + } + if (n == 0) { + if(rbuf == (char*)0) + tot = 0; /* process died between our open and read */ + break; /* we're done */ } - if (end_of_file && (n == 0 || buf[n-1]))/* last read char not null */ - buf[n++] = '\0'; /* so append null-terminator */ rbuf = xrealloc(rbuf, tot + n); /* allocate more memory */ memcpy(rbuf + tot, buf, n); /* copy buffer into it */ tot += n; /* increment total byte ctr */ - if (end_of_file) - break; - } + } while (n >= (sizeof(buf) - 1)); + close(fd); - if (n <= 0 && !end_of_file) { + + if (tot == 0) { if (rbuf) free(rbuf); - return NULL; /* read error */ + return NULL; /* read error */ + } + if (rbuf[tot-1]) { /* last read char not null */ + rbuf = xrealloc(rbuf, tot + 1); /* allocate more memory */ + rbuf[tot++] = '\0'; /* and append null-terminator */ } + endbuf = rbuf + tot; /* count space for pointers */ align = (sizeof(char*)-1) - ((tot + sizeof(char*)-1) & (sizeof(char*)-1)); for (c = 0, p = rbuf; p < endbuf; p++) { @@ -626,7 +627,7 @@ static int read_unvectored(char *restric unsigned n = 0; snprintf(path, sizeof(path), "%s/%s", whom, what); - fd = open(path, O_RDONLY); + fd = open(path, O_RDONLY, O_NOATIME); if(fd==-1) return 0; for(;;){
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor