mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
more robust win
This commit is contained in:
parent
8ba3811378
commit
4b970769b9
1 changed files with 18 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue