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: SUMMARY: EPIPE on fread...Why? (CERN httpd)
Date: Mon, 29 Apr 1996 19:05:51 +0000	[thread overview]
Message-ID: <96076331021537.tru64-unix-managers.marc@archive.invalid> (raw)

Hi,
	I posted to this list on April 9 and haven't heard anything.  
Since then I've been ignoring EPIPEs generated by fread(3) and that has 
not caused any visable problems in those 3 weeks.  I still have no idea
why an fread() causes an EPIPE.  I'm including the original post and the
context diff (patch) that I made.

			Sean

On Tue, 9 Apr 1996, I wrote:

> 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. deleted]
Here is the patch.  It should be applied in the WWW directory:
--------------------cut here----------------------------------------------
*** Daemon/Implementation/HTRequest.c.orig	Fri Aug 12 03:36:29 1994
--- Daemon/Implementation/HTRequest.c	Mon Apr 29 11:30:02 1996
***************
*** 6,16 ****
--- 6,22 ----
  **	AL	Ari Luotonen    luotonen@dxcern.cern.ch
  **	MD	Mark Donszelmann    duns@vxdeop.cern.ch
  **
+ ** CONTRIBUTORS:
+ **      SW	Sean Watson	swatson@ultrix6.cs.csubak.edu
+ **
  ** HISTORY:
  **	11 Dec 93  AL	Written based on the old HTHandle().
  **	 8 Jul 94  FM	Insulate free() from _free structure element.
  **			Replaced free() with FREE() is some places where
  **			the pointer might already have been freed.
+ **      29 Apr 96  SW   Fixed problem with buf_put_block() so it doesn't croak
+ **                      on zero length blocks.  (Actually I just documented it 
+ **                      for the patch file.)
  */
  
  #include <string.h>
***************
*** 660,665 ****
--- 666,677 ----
  				 CONST char *,	b,
  				 int,		l)
  {
+     /* For some reason, this can be called with l==0.  DEC-Unix chokes in
+        this curcumstance, so we add the following failsafe (since this function
+        should be a no-op if l == 0) */
+     if (!l)
+       return;
+ 
      me->content_count += l;
  
      if (TRACE && me->content_count > me->last_verbose + DEFAULT_CNT_BUF_SIZE) {
*** Daemon/Implementation/HTScript.c.orig	Sun Sep 25 06:52:58 1994
--- Daemon/Implementation/HTScript.c	Mon Apr 29 11:15:03 1996
***************
*** 6,11 ****
--- 6,15 ----
  **	AL	Ari Luotonen	luotonen@dxcern.cern.ch
  **	MD	Mark Donszelmann    duns@vxdeop.cern.ch
  **
+ ** Contributors:
+ **      FM      Foteos Macrides macrides@sci.wfbr.edu  ?? This is a guess ??
+ **      SW      Sean Watson     swatson@ultrix6.cs.csubak.edu
+ **
  ** HISTORY:
  **	31 Oct 93  AL	Written from scratch.
  **	 6 Nov 93  MD	Made VMS compatibility.
***************
*** 38,43 ****
--- 42,49 ----
  **			added it to 216-1betavms last May, and VMSers are
  **			using it).
  **	 8 Jul 94  FM	Insulate free() from _free structure element.
+ **       9 Apr 96  SW   Added code so DEC-Unix generated EPIPE's won't stop us
+ **                      from reading script results.
  **
  **
  ** BUGS:
***************
*** 49,54 ****
--- 55,64 ----
  #include <stdio.h>
  #include <time.h>
  
+ #ifdef __osf__
+ #include <errno.h>
+ #endif /* __osf__ */
+ 
  #ifdef Mips
  #include <sys/wait.h>
  #endif
***************
*** 203,208 ****
--- 213,227 ----
  
  	if (status == 0) { /* EOF or error */
  	    if (ferror(fp) == 0) break;
+ #ifdef __osf__
+ 	    if (ferror(fp) == EPIPE)
+ 	      {
+ 	      CTRACE(stderr,"HTLoadScriptResult: read returns %d, ignored\n",
+ 		     ferror(fp));
+ 	      clearerr(fp);
+ 	      continue;
+ 	      }
+ #endif /*__osf__*/
  	    CTRACE(stderr,"HTLoadScriptResult: Read error, read returns %d\n",
  		   ferror(fp));
  	    break;

                 reply	other threads:[~1996-04-29 19:05 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