9 void stdin_pre_select(struct sched *s, struct task *t)
11 struct stdin_task *sit = t->private_data;
12 if (sit->loaded < sit->bufsize)
13 para_fd_set(STDIN_FILENO, &s->rfds, &s->max_fileno);
14 t->ret = 1; /* success */
17 static void stdin_default_event_handler(struct task *t)
19 PARA_NOTICE_LOG("%p: %s\n", t, PARA_STRERROR(-t->ret));
23 void stdin_post_select(struct sched *s, struct task *t)
25 struct stdin_task *sit = t->private_data;
29 if (sit->loaded >= sit->bufsize)
31 if (!FD_ISSET(STDIN_FILENO, &s->rfds))
33 ret = read(STDIN_FILENO, sit->buf + sit->loaded, sit->bufsize - sit->loaded);
35 t->ret = -E_STDIN_READ;
40 t->ret = -E_STDIN_EOF;
45 void stdin_set_defaults(struct stdin_task *sit)
47 sit->bufsize = 16 * 1024,
51 sit->task.pre_select = stdin_pre_select;
52 sit->task.post_select = stdin_post_select;
53 sit->task.event_handler = stdin_default_event_handler;
54 sit->task.private_data = sit;
55 sprintf(sit->task.status, "stdin reader");