#include #include #define N 8000 void copy(int fd, int pid) { int i, j, m, w, partial, nb; Rune r; char *t; char buf[32+N], *b; m = sprint(buf, "d%d\n", pid); b = buf+m; partial = 0; for(;;){ nb = partial+read(0, b+partial, N-m-partial-1); /* -1 to leave terminal \0 */ if(nb <= 0) break; b[partial+nb] = '\0'; if(strlen(b) < nb){ /* nulls in data */ t = malloc(nb+1); if(t == nil){ fprint(2, "wnew: malloc error: %r\n"); exits("malloc"); } for(i=j=0; i0) for(i=0; i