Code to write to cache file

This commit is contained in:
Kovid Goyal
2020-12-31 15:18:30 +05:30
parent c346cbc252
commit 99d2647335
3 changed files with 127 additions and 34 deletions

View File

@@ -68,3 +68,17 @@ self_pipe(int fds[2], bool nonblock) {
return pipe2(fds, flags) == 0;
#endif
}
static inline void
drain_fd(int fd) {
static uint8_t drain_buf[1024];
while(true) {
ssize_t len = read(fd, drain_buf, sizeof(drain_buf));
if (len < 0) {
if (errno == EINTR) continue;
break;
}
if (len > 0) continue;
break;
}
}