X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=stdout.c;h=f857814a93ef8310669ca4138156a31394767a8c;hp=83703055c83c54edc9a7e17b050f3ca2d076c61e;hb=fbcc28c36aa7d5e07874e473cbaf044124afd63b;hpb=39ef1da5509461b18beb5b8f16ff6118c20c0ac6 diff --git a/stdout.c b/stdout.c index 83703055..f857814a 100644 --- a/stdout.c +++ b/stdout.c @@ -12,8 +12,14 @@ void stdout_pre_select(struct sched *s, struct task *t) t->ret = 1; sot->check_fd = 0; - if (!*sot->loaded) + if (!*sot->loaded) { + if (*sot->input_eof) { + t->ret = -E_STDOUT_EOF; + s->timeout.tv_sec = 0; + s->timeout.tv_usec = 1; + } return; + } sot->check_fd = 1; para_fd_set(STDOUT_FILENO, &s->wfds, &s->max_fileno); } @@ -25,7 +31,7 @@ void stdout_post_select(struct sched *s, struct task *t) t->ret = 1; if (!sot->check_fd) { - if (*sot->eof) + if (*sot->input_eof) t->ret = -E_STDOUT_EOF; return; } @@ -38,3 +44,20 @@ void stdout_post_select(struct sched *s, struct task *t) *sot->loaded -= ret; t->ret = 1; } + +void stdout_default_event_handler(struct task *t) +{ + PARA_NOTICE_LOG("%p: %s\n", t, PARA_STRERROR(-t->ret)); + unregister_task(t); +} + + +void stdout_set_defaults(struct stdout_task *sot) +{ + sot->task.private_data = sot; + sot->task.pre_select = stdout_pre_select; + sot->task.post_select = stdout_post_select; + sot->task.event_handler = stdout_default_event_handler; + sot->eof = 0; + sprintf(sot->task.status, "stdout writer"); +}