diff options
author | rsc <devnull@localhost> | 2005-03-05 13:11:00 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-03-05 13:11:00 +0000 |
commit | 4b970769b9bbc68042daa320ca1bd28a73614502 (patch) | |
tree | 0f5d047cfbc54ff169916a53fa89bb1b4f33300d /src/cmd | |
parent | 8ba3811378e9e10d0fc363e152ef7ea40a658463 (diff) | |
download | plan9port-4b970769b9bbc68042daa320ca1bd28a73614502.tar.gz plan9port-4b970769b9bbc68042daa320ca1bd28a73614502.tar.bz2 plan9port-4b970769b9bbc68042daa320ca1bd28a73614502.zip |
more robust win
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/9term/win.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c index 1e43a0f9..21676c60 100644 --- a/src/cmd/9term/win.c +++ b/src/cmd/9term/win.c @@ -63,7 +63,7 @@ Channel *cwait; int pid = -1; int label(char*, int); -void error(char*); +void error(char*, ...); void stdinproc(void*); void stdoutproc(void*); void type(Event*, int, CFid*, CFid*); @@ -206,8 +206,15 @@ threadmain(int argc, char **argv) } void -error(char *s) +error(char *s, ...) { + va_list arg; + + if(s){ + va_start(arg, s); + s = vsmprint(s, arg); + va_end(arg); + } if(s) fprint(2, "win: %s: %r\n", s); else @@ -478,8 +485,15 @@ stdoutproc(void *v) buf[n] = 0; qlock(&q.lk); m = sprint(x, "#%d", q.p); - if(fswrite(afd, x, m) != m) - error("stdout writing address"); + if(fswrite(afd, x, m) != m){ + fprint(2, "stdout writing address: %r; resetting\n"); + fswrite(afd, "$", 1); + m = fsread(afd, x, sizeof x-1); + if(m >= 0){ + x[m] = 0; + q.p = atoi(x); + } + } if(fswrite(dfd, buf, n) != n) error("stdout writing body"); q.p += nrunes(buf, n); |