X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=stdin.c;h=0b84cdc72011e369bf290f671ae96d6e8cab8569;hp=facbf47395fae85b3396197118e6edf68a6cf90c;hb=2d945f96dcd02bcabd02a79342712e089ed30c98;hpb=f45846b1a228c806424e6bf937ba09e648e87441 diff --git a/stdin.c b/stdin.c index facbf473..0b84cdc7 100644 --- a/stdin.c +++ b/stdin.c @@ -31,6 +31,11 @@ static void stdin_pre_select(struct sched *s, struct task *t) { struct stdin_task *sit = container_of(t, struct stdin_task, task); + + if (sit->output_error && *sit->output_error < 0) { + t->error = *sit->output_error; + return; + } t->error = 0; sit->check_fd = 0; if (sit->loaded >= sit->bufsize) @@ -55,6 +60,10 @@ static void stdin_post_select(struct sched *s, struct task *t) struct stdin_task *sit = container_of(t, struct stdin_task, task); ssize_t ret; + if (sit->output_error && *sit->output_error < 0) { + t->error = *sit->output_error; + return; + } t->error = 0; if (!sit->check_fd) return; @@ -75,22 +84,21 @@ static void stdin_post_select(struct sched *s, struct task *t) * \param sit The stdin task structure. * * This fills in the pre/post select function pointers of the task structure - * given by \a sit. It also sets up a default error handler which unregisters - * the task. Moreover, \a loaded and \a eof are set to zero and \a bufsize is - * initialized to 16 KB (but no buffer is allocated). + * 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->loaded = 0, 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; + sit->output_error = NULL; PARA_EMERG_LOG("%s\n", para_strerror(-ret)); exit(EXIT_FAILURE); }