+ if (sot->must_set_nonblock_flag) {
+ ret = mark_fd_nonblocking(STDOUT_FILENO);
+ if (ret < 0)
+ goto out;
+ sot->must_set_nonblock_flag = false;
+ }
+ for (;;) {
+ sz = btr_next_buffer(btrn, &buf);
+ if (sz == 0)
+ break;
+ ret = xwrite(STDOUT_FILENO, buf, sz);
+ if (ret <= 0)
+ break;
+ btr_consume(btrn, ret);
+ }
+out:
+ if (ret < 0) {
+ btr_remove_node(&sot->btrn);
+ /* Revert to blocking mode if necessary. */
+ fcntl(STDOUT_FILENO, F_SETFL, sot->fd_flags);
+ }
+ return 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.
+ */