Make sure read_all sets errno to 0 at EOF.
This commit is contained in:
parent
6b6e6b7520
commit
c0ca1a9f50
@ -23,6 +23,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
int write_all(int fd, void *buf, int size)
|
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) {
|
while (got_read < size) {
|
||||||
ret = read(fd, (char *) buf + got_read, size - got_read);
|
ret = read(fd, (char *) buf + got_read, size - got_read);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
errno = 0;
|
||||||
fprintf(stderr, "EOF\n");
|
fprintf(stderr, "EOF\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user