blob: a04496d8ff026c25dab763c25f0c1fd100e040c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#ifndef UTIL_LINUX_WRITEALL_H
#define UTIL_LINUX_WRITEALL_H
#include <string.h>
#include <unistd.h>
#include <errno.h>
static inline int write_all(int fd, const void *buf, size_t count)
{
while(count) {
ssize_t tmp;
errno = 0;
tmp = write(fd, buf, count);
if (tmp > 0) {
count -= tmp;
if (count)
buf += tmp;
} else if (errno != EINTR && errno != EAGAIN)
return -1;
}
return 0;
}
#endif /* UTIL_LINUX_WRITEALL_H */
|