- t->ret = -E_STDOUT_WRITE;
- ret = write(STDOUT_FILENO, sot->buf, *sot->loaded);
- if (ret <= 0)
+
+ for (;;) {
+ sz = btr_next_buffer(btrn, &buf);
+ if (sz == 0)
+ break;
+ ret = write_nonblock(STDOUT_FILENO, buf, sz);
+ if (ret <= 0)
+ break;
+ btr_consume(btrn, ret);
+ }
+out:
+ if (ret < 0)
+ btr_remove_node(btrn);
+ t->error = ret;
+}
+/**
+ * Initialize a stdout task structure with default values.
+ *
+ * \param sot The stdout task structure.
+ *
+ * This fills in the pre/post select function pointers of the task structure
+ * given by \a sot and sets the stdout file descriptor to nonblocking mode.
+ */
+void stdout_set_defaults(struct stdout_task *sot)
+{
+ int ret;
+
+ sot->task.pre_select = stdout_pre_select;
+ sot->task.post_select = stdout_post_select;
+ sprintf(sot->task.status, "stdout");
+ ret = mark_fd_nonblocking(STDOUT_FILENO);
+ if (ret >= 0)