sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

writeall.c (318B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <unistd.h>
      3 
      4 #include "../util.h"
      5 
      6 ssize_t
      7 writeall(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 }