/* xwrite() is the same a write(), but it automatically restarts write() operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT GUARANTEE that "len" bytes is written even if the operation is successful.  */
static ssize_t xwrite(int fd, const void *buf, size_t len)
/* xwrite() is the same a write(), but it automatically restarts write() operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT GUARANTEE that "len" bytes is written even if the operation is successful.  */
static ssize_t xwrite(int fd, const void *buf, size_t len)
{
	ssize_t nr;
	while (1) {
		nr = write(fd, buf, len);
		if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
			continue;
		return nr;
	}
}