ref: b95c125ec95154a0a834e10796fdd62eee348c87
parent: 036047c24d4fdaeb5f2574adab2909b9a1717a2a
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Dec 22 08:35:10 EST 2019
don't report an error on eof
--- a/9pex.c
+++ b/9pex.c
@@ -77,7 +77,7 @@
static char *Eisdir = "is a directory";
static char *Ebadoffset = "bad offset";
-static int in, out;
+static int in, out, eof;
static C9ctx ctx;
static int debug = 1;
static Fid **fids;
@@ -451,8 +451,11 @@
used(c);
*err = 0;
- if ((n = read(in, rdbuf, size)) != (int)size) { /* unexpected eof */
- *err = 1;
+ if ((n = read(in, rdbuf, size)) != (int)size) {
+ if (n == 0)
+ eof = 1;
+ else
+ *err = 1;
return NULL;
}
@@ -700,6 +703,7 @@
in = 0;
out = 1;
+ eof = 0;
fids = NULL;
numfids = 0;
tags = NULL;
@@ -717,7 +721,7 @@
wrbuf = calloc(1, ctx.msize);
wroff = 0;
- for (;;) {
+ for (; !eof;) {
if ((can = canrw(1)) < 0)
break;
if ((can & Canrd) != 0 && s9proc(&ctx) != 0)