I included <error.h>
.
#include <error.h>
#include <unistd.h>
ssize_t rio_readn(int fd, void *buf, size_t n)
{
size_t nleft = n;
char *rbuf = buf;
while(nleft > 0)
{
int nread = read(fd, rbuf, nleft);
if(nread < 0)
{
if(error == EINTR)
nread = 0;
else
return -1;
}
else if(nread == 0)
break;
nleft -= nread;
rbuf += nread;
}
return n - nleft;
}
答案 0 :(得分:8)
You're missing the declaration for EINTR
because <error.h>
has no relation to <errno.h>
, which is where EINTR
is declared. And the error variable is errno
and not error
, too.