[comp.os.minix] fix to libupack for pipes

lmjm@doc.ic.ac.uk (Lee McLoughlin) (06/01/88)

In reply to the problems with lorder.  I found that it was going wrong
because libupack was trying to send it too much data down a pipe. Any more
than 7K and the write will fail.  Libupack also ignores failed writes - I
did not fix this.

Most programs are not effected by the write-to-pipe limit
because they use stdio which doesn't belt out so much data in one chunk.

Here is the necessary fix.  Basically it ouputs in 7K chunks.

0a1,3
> /* Limit on bytes that can be writen to a pipe */
> #define OUTMAX (7*1024)
> 
130a134
>   char *o;
137c141,145
< 	n = write(1, output, count);
---
> 	for( o = output; count > 0; o += OUTMAX ){
> 		int out = (count > OUTMAX) ? OUTMAX : count;
> 		n = write(1, o, out);
> 		count -= out;
> 	}

--
UKUUCP SUPPORT  Lee McLoughlin
	"What you once thought was only a nightmare is now a reality!"

Janet: lmjm@uk.ac.ic.doc, lmcl@uk.ac.ukc
DARPA: lmjm@doc.ic.ac.uk (or lmjm%uk.ac.ic.doc@nss.cs.ucl.ac.uk)
Uucp:  lmjm@icdoc.UUCP, ukc!icdoc!lmjm