add open_read_close() and similar stuff

This commit is contained in:
Denis Vlasenko
2006-10-14 02:23:43 +00:00
parent 88ca067690
commit ea62077b85
38 changed files with 228 additions and 234 deletions

View File

@@ -22,15 +22,9 @@
static int read_to_buf(const char *filename, void *buf)
{
int fd;
ssize_t ret;
fd = open(filename, O_RDONLY);
if (fd < 0)
return -1;
ret = read(fd, buf, PROCPS_BUFSIZE-1);
((char *)buf)[ret > 0 ? ret : 0] = 0;
close(fd);
ret = open_read_close(filename, buf, PROCPS_BUFSIZE-1);
((char *)buf)[ret > 0 ? ret : 0] = '\0';
return ret;
}