diff options
Diffstat (limited to '')
-rw-r--r-- | writeall.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/writeall.c b/writeall.c new file mode 100644 index 0000000..2e3d1ad --- /dev/null +++ b/writeall.c @@ -0,0 +1,21 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +void +writeall(int fd, const void *data, size_t n, const char *fname) +{ + const char *text = data; + ssize_t r; + + while (n) { + r = write(fd, text, n); + if (r < 0) { + if (errno == EINTR) + continue; + eprintf("write %s:", fname); + } + n -= (size_t)r; + text = &text[r]; + } +} |