X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=stdin.c;h=8eb86dee69ba7322524e960bba6169916e9bef14;hp=b9b2e8bfa6355684e3ea703de2e0ba6eee813153;hb=08aa4b386c981292aec04fc35fe37133047fb946;hpb=3b45609699cebbc20178b435f30adbab14d9e42a diff --git a/stdin.c b/stdin.c index b9b2e8bf..8eb86dee 100644 --- a/stdin.c +++ b/stdin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2008 Andre Noll + * Copyright (C) 2006-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -9,9 +9,7 @@ #include /* readdir() */ #include - #include "para.h" -#include "string.h" #include "list.h" #include "sched.h" #include "fd.h" @@ -31,6 +29,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 +58,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,9 +82,8 @@ 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) { @@ -90,6 +96,7 @@ void stdin_set_defaults(struct stdin_task *sit) 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); }