/* Read a pipe, waiting for a full buffer */ int readp(fd, buf, reqst) int fd; /* File descriptor number */ char *buf; /* Input buffer */ int reqst; /* Requested byte count */ { /* How many bytes read sofar, and how many got each time */ register int sofar, got, rcnt; sofar = 0; rcnt = reqst; do { got = read(fd, buf + sofar, rcnt - sofar); if(got == -1) return(got); sofar += got; /* Increment number of characters so far */ } while (got != 0 && sofar != rcnt); return(sofar); }