master xplshn/aruu / shared / libutil / writeall.c
 1/* See LICENSE file for copyright and license details. */
 2#include <unistd.h>
 3
 4#include "../util.h"
 5
 6ssize_t
 7writeall(int fd, const void *buf, size_t len)
 8{
 9	const char *p = buf;
10	ssize_t n;
11
12	while (len) {
13		n = write(fd, p, len);
14		if (n <= 0)
15			return n;
16		p += n;
17		len -= n;
18	}
19
20	return p - (const char *)buf;
21}