+static void stdout_post_select_btr(struct sched *s, struct task *t)
+{
+ struct stdout_task *sot = container_of(t, struct stdout_task, task);
+ struct btr_node *btrn = sot->btrn;
+ int ret;
+ char *buf;
+ size_t sz;
+
+ t->error = 0;
+ ret = btr_node_status(btrn, 0, BTR_NT_LEAF);
+ if (ret < 0)
+ goto out;
+ if (ret == 0)
+ return;
+ if (!FD_ISSET(STDOUT_FILENO, &s->wfds))
+ return;
+
+ for (;;) {
+ sz = btr_next_buffer(btrn, &buf);
+ if (sz == 0)
+ break;
+ ret = write_nonblock(STDOUT_FILENO, buf, sz, 0);
+ if (ret <= 0)
+ break;
+ btr_consume(btrn, ret);
+ }
+out:
+ if (ret < 0)
+ btr_remove_node(btrn);
+ t->error = ret;
+}