-
- write_left = count;
- index = 0;
- do {
- write_len = write(pipe->fd[1], buf + index, write_left);
- if (write_len < 0) {
- ret = -errno;
- if (errno == EINTR) {
- /* Read again. */
- continue;
- } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
- /*
- * Return the number of bytes read up to this point if any.
- */
- if (index) {
- ret = index;
- }
- goto error;
- } else {
- PERROR("lttng pipe write");
- goto error;
- }
- }
- write_left -= write_len;
- index += write_len;
- } while (write_left > 0);
-
- /* Everything went fine. */
- ret = index;
-