#include <unistd.h>
#include <sys/types.h>
-#ifdef _WIN32
-#include <winsock.h>
-#else
+#ifndef _WIN32
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/socket.h>
if (fp->type == KNF_TYPE_LOCAL) { // on Windows, the following block is necessary; not on UNIX
off_t rest = len, curr;
while (rest) {
- curr = read(fp->fd, buf + l, rest);
+ do {
+ curr = read(fp->fd, buf + l, rest);
+ } while (curr < 0 && EINTR == errno);
+ if (curr < 0) return -1;
if (curr == 0) break;
l += curr; rest -= curr;
}
else if (whence==SEEK_SET)
fp->offset = off;
fp->is_ready = 0;
- return fp->offset;
+ return 0;
}
errno = EINVAL;
fprintf(stderr,"[knet_seek] %s\n", strerror(errno));