-static void stdout_default_event_handler(struct task *t)
-{
- PARA_NOTICE_LOG("%p: %s\n", t, PARA_STRERROR(-t->ret));
- unregister_task(t);
+ 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;