Hi,
I've got a program that's calling fread(3) on a pipe and returning
-1. When ferror(3) is called on the file descriptor, I get EPIPE (32).
The man page for fread(3) refers me to putc(3) which says you get an EPIPE
when you try to write to a pipe whose reading end has been closed. The
same goes for the intro(2) man page. Grepping through the man pages for
EPIPE yeilds
fclose(3), fputws(3), fseek(3), printf(3), putc(3), puts(3), putwc(3),
intro(2), write(2) but NOTHING that has much to do with read/fread.
What makes fread set errno to EPIPE? Is EPIPE safe to ignore when it
is generated by fread (right now I've patched it to do this)?
Thanks,
Sean
P.S. The pogram is CERN httpd. I have applied the kludge/patch they mention
(ie, I've added a sleep(1) to the HTScript.c file) but this dosn't solve
all the problems or tell me why it is happening.
P.P.S. Here are the pertinent (slightly modified) code fragments:
int pout[0];
FILE *fp;
pipe(pout);
/* ... */
fp = fdopen(pout[0], "r");
/* ... */
for (;;)
{
int status = fread(input_buffer, 1, INPUT_BUFFER_SIZE, fp);
if (status == 0) { /* EOF or error */
if (ferror(fp) == 0) break;
#ifdef osf_fread_fix
if (ferror(fp) == EPIPE) continue;
#endif
fprintf(stderr,"HTLoadScriptResult: Read error, read returns %d\n",
ferror(fp));
break;
}
/* ... */
}
Received on Tue Apr 09 1996 - 22:58:55 NZST