-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuio.c
More file actions
28 lines (26 loc) · 635 Bytes
/
uio.c
File metadata and controls
28 lines (26 loc) · 635 Bytes
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
26
27
28
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
size_t
writeuio(int fd, struct iovec *iov, int cnt)
{
size_t pos = 0;
ssize_t res;
n = iov[0].iov_cnt;
while (n > pos) {
poll_wait(fd, POLLOUT | POLLERR);
res = writev (fd, iov[0].iov_base + pos, n - pos);
switch ((int)res) {
case -1:
if (errno == EINTR || errno == EAGAIN)
continue;
return 0;
case 0:
errno = EPIPE;
return pos;
default:
pos += (size_t)res;
}
}
return (pos);
}