tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Sean Watson <swatson () tuolumne ! lib ! csubak ! edu>
To: tru64-unix-managers
Subject: EPIPE on fread...Why?  (CERN httpd)
Date: Tue, 09 Apr 1996 20:24:00 +0000	[thread overview]
Message-ID: <96076331021227.tru64-unix-managers.marc@archive.invalid> (raw)

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;
    }
  /* ... */
  }

                 reply	other threads:[~1996-04-09 20:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox