check_wav: return error on premature end of file.
[paraslash.git] / stdin.c
diff --git a/stdin.c b/stdin.c
index cecdcb7..6b9c809 100644 (file)
--- a/stdin.c
+++ b/stdin.c
@@ -27,22 +27,14 @@ void stdin_post_select(struct sched *s, struct task *t)
        ret = read(STDIN_FILENO, sit->buf + sit->loaded, sit->bufsize - sit->loaded);
        if (ret < 0)
                t->ret = -E_STDIN_READ;
-       else {
+       else if (ret > 0) {
                sit->loaded += ret;
                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);
 }
-
-#if 0
-void stdin_init(struct stdin_task *sit)
-{
-       sit->task.private_data = sit;
-       sit->task.pre_select = stdin_pre_select;
-       sit->task.post_select = stdin_post_select;
-       sit->task.flags = POST_EOF_IS_ERROR;
-       sprintf(sit->task.status, "%p stdin reader: initialized", &sit->task);
-}
-#endif