- t->ret = ret;
- } else
- t->ret = 0;
- if (ret <= 0)
- sit->eof = 1;
- sprintf(t->status,
- "%p stdin reader: loaded = %d, ret = %d",
- sit, sit->loaded, t->ret);
+ else
+ t->error = -E_STDIN_EOF;
+}
+
+/**
+ * Initialize a stdin task structure with default values.
+ *
+ * \param sit The stdin task structure.
+ *
+ * This fills in the pre/post select function pointers of the task structure
+ * given by \a sit. Moreover, the stdin file desctiptor is set to nonblocking
+ * mode and \a bufsize is initialized to 16 KB (but no buffer is allocated).
+ */
+void stdin_set_defaults(struct stdin_task *sit)
+{
+ int ret;
+
+ sit->bufsize = 16 * 1024,
+ sit->task.pre_select = stdin_pre_select;
+ sit->task.post_select = stdin_post_select;
+ sprintf(sit->task.status, "stdin reader");
+ ret = mark_fd_nonblocking(STDIN_FILENO);
+ if (ret >= 0)
+ return;
+ PARA_EMERG_LOG("%s\n", para_strerror(-ret));
+ exit(EXIT_FAILURE);