mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +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 pid = -1;
|
||||||
|
|
||||||
int label(char*, int);
|
int label(char*, int);
|
||||||
void error(char*);
|
void error(char*, ...);
|
||||||
void stdinproc(void*);
|
void stdinproc(void*);
|
||||||
void stdoutproc(void*);
|
void stdoutproc(void*);
|
||||||
void type(Event*, int, CFid*, CFid*);
|
void type(Event*, int, CFid*, CFid*);
|
||||||
|
@ -206,8 +206,15 @@ threadmain(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
if(s)
|
||||||
fprint(2, "win: %s: %r\n", s);
|
fprint(2, "win: %s: %r\n", s);
|
||||||
else
|
else
|
||||||
|
@ -478,8 +485,15 @@ stdoutproc(void *v)
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
qlock(&q.lk);
|
qlock(&q.lk);
|
||||||
m = sprint(x, "#%d", q.p);
|
m = sprint(x, "#%d", q.p);
|
||||||
if(fswrite(afd, x, m) != m)
|
if(fswrite(afd, x, m) != m){
|
||||||
error("stdout writing address");
|
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)
|
if(fswrite(dfd, buf, n) != n)
|
||||||
error("stdout writing body");
|
error("stdout writing body");
|
||||||
q.p += nrunes(buf, n);
|
q.p += nrunes(buf, n);
|
||||||
|
|
Loading…
Reference in a new issue