void plumbproc(void *argv) { Channel *c; int i, n, which, *fdp; void **arg; arg = argv; c = arg[0]; fdp = arg[1]; i = 0; for(;;){ i = 1-i; /* toggle */ n = read(*fdp, plumbbuf[i].data, READBUFSIZE); if(n <= 0){ fprint(2, "samterm: plumb read error: %r\n"); threadexits("plumb"); /* not a fatal error */ } plumbbuf[i].n = n; if(plumbformat(i)){ which = i; send(c, &which); } } }
void plumbproc(void *arg) { CFid *fid; int i; Plumbmsg *m; fid = arg; i = 0; for(;;){ m = plumbrecvfid(fid); if(m == nil){ fprint(2, "samterm: plumb read error: %r\n"); threadexits("plumb"); /* not a fatal error */ } if(plumbformat(m, i)){ send(plumbc, &i); i = 1-i; /* toggle */ } } }