Make sure read_all sets errno to 0 at EOF.

This commit is contained in:
Rafal Wojtczuk 2011-03-15 10:36:50 +01:00
parent 6b6e6b7520
commit c0ca1a9f50

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
int write_all(int fd, void *buf, int size)
{
@ -47,6 +48,7 @@ int read_all(int fd, void *buf, int size)
while (got_read < size) {
ret = read(fd, (char *) buf + got_read, size - got_read);
if (ret == 0) {
errno = 0;
fprintf(stderr, "EOF\n");
return 0;
}