# HG changeset patch # User Richard M. Stallman # Date 799997745 0 # Node ID 6ae23eecab6ac18cb3269bc4002eee5d5ae54d4f # Parent 6234b3610a6f44897268b709a32db61e3ba80c35 (Fcall_process): Keep reading till buffer is nearly full. diff -r 6234b3610a6f -r 6ae23eecab6a src/callproc.c --- a/src/callproc.c Tue May 09 05:17:02 1995 +0000 +++ b/src/callproc.c Tue May 09 05:35:45 1995 +0000 @@ -497,16 +497,33 @@ int first = 1; int total_read = 0; - while ((nread = read (fd[0], bufptr, bufsize)) != 0) + while (1) { - if (nread < 0) + /* Repeatedly read until we've filled as much as possible + of the buffer size we have. But don't read + less than 1024--save that for the next bufferfull. */ + + nread = 0; + while (nread < bufsize - 1024) { -#if defined (__osf__) && defined (__alpha) - continue; /* Work around bug in DEC OSF/1 V3.0. */ -#else - break; -#endif + int this_read + = read (fd[0], bufptr + nread, bufsize - nread); + + if (this_read < 0) + goto give_up; + + if (this_read == 0) + goto give_up_1; + + nread += this_read; } + + give_up_1: + + /* Now NREAD is the total amount of data in the buffer. */ + if (nread == 0) + break; + immediate_quit = 0; total_read += nread; @@ -531,6 +548,7 @@ immediate_quit = 1; QUIT; } + give_up: ; } /* Wait for it to terminate, unless it already has. */