Subject: Pipe problem?

From: Alan Watson <[email-masked]>
Date: Thu, 19 Nov 1992 14:56:13 -0500

Before I investigate further, has anyone come across this sort of
a problem with the pipe (|) command:

	; sam -d
	a
	Hello world!
	.
	,p
	Hello world!
	|/bin/cat
	?warning: exit status not 0
	!
	,p
	Hello world!
	|wc
	?warning: exit status not 0
	!
	,p
	      1       2      13
	q
	?changed files
	q
	;

I checked "waitfor", and the child processes really are exiting with
non-zero status!  I'm on a Decstation running Ultrix 4.3, and I
compiled sam with gcc in POSIX mode.

Alan.

---

From: Alan Watson <[email-masked]>
Date: Thu, 19 Nov 1992 19:38:23 -0500

There appears to be at least two things going on here.

There is a simple bug in sam, which causes the "producer" process which
feeds dot into the "consumer" process created by the pipe command, to
exit with the wrong status.  The diffs to correct this bug are below.

However, waitfor should filter out this non-zero status, as it does not
come from the "consumer" process; apparently it does behave correctly
under SunOS, but not under Ultrix 4.2 or 4.3.  I can neither fault
waitfor's logic nor reproduce this behaviour with a simple program.  I'm
giving up for now, but if anyone can figure this one out I'd very much
like to hear an explanation.

Alan.

*** shell.c     Thu Nov 19 18:22:18 1992
--- ../Orig/sam/shell.c Thu Nov 19 18:19:55 1992
***************
*** 79,85 ****
                                                free(c);
                                        }
                                }
!                               exits(retcode? 0 : "error");
                        }
                        if(pid==-1){
                                fprint(2, "Can't fork?!\n");
--- 79,85 ----
                                                free(c);
                                        }
                                }
!                               exits(retcode? "error" : 0);
                        }
                        if(pid==-1){
                                fprint(2, "Can't fork?!\n");