diff -rc2N tcsh-6.00.02.orig/Makefile tcsh-6.00.02/Makefile
*** tcsh-6.00.02.orig/Makefile	Sat Sep 21 20:10:39 1991
--- tcsh-6.00.02/Makefile	Thu Oct 10 21:00:58 1991
***************
*** 26,30 ****
  
  #CFLAGS= -I. -g
! #CFLAGS= -I. -O
  
  #CFLAGS= -g -pg -I. -DPROF
--- 26,30 ----
  
  #CFLAGS= -I. -g
! CFLAGS= -I. -O
  
  #CFLAGS= -g -pg -I. -DPROF
***************
*** 35,39 ****
  
  # gcc 1.37+
! CFLAGS=-O -I. -fcombine-regs -finline-functions -fstrength-reduce #-msoft-float
  
  #CFLAGS= -O -I. -fvolatile
--- 35,39 ----
  
  # gcc 1.37+
! #CFLAGS=-O -I. -fcombine-regs -finline-functions -fstrength-reduce #-msoft-float
  
  #CFLAGS= -O -I. -fvolatile
***************
*** 74,80 ****
  ## LIBES.  Pick one, or roll your own.
  ################################################################
! LIBES= -ltermcap		## BSD style things, hpux
  #LIBES= -ltermcap -lcs		## Mach
! #LIBES= -lcurses		## Sys V3 w/o networking
  #LIBES= -lcurses -lnet		## Sys V3 with networking
  #LIBES= -lcurses -ldir		## Sys V2 w/o networking [needs directory lib]
--- 74,81 ----
  ## LIBES.  Pick one, or roll your own.
  ################################################################
! #LIBES= -ltermcap		## BSD style things, hpux
  #LIBES= -ltermcap -lcs		## Mach
! LIBES= -lcurses			## Sys V3 w/o networking (and Sys V4)
! #LIBES= -lcurses -lc /usr/ucblib/libucb.a	## Sys V4 with BSDTIMES
  #LIBES= -lcurses -lnet		## Sys V3 with networking
  #LIBES= -lcurses -ldir		## Sys V2 w/o networking [needs directory lib]
***************
*** 99,105 ****
  # If you want to take out -traditional, make sure that your sys/ioctl.h
  # is fixed correctly, otherwise you'll be stopped for tty input!
! CC=	gcc -Wall 
  #CC=	cc
  #CC=	occ
  ED=	-ed
  AS=	-as
--- 100,107 ----
  # If you want to take out -traditional, make sure that your sys/ioctl.h
  # is fixed correctly, otherwise you'll be stopped for tty input!
! #CC=	gcc -Wall 
  #CC=	cc
  #CC=	occ
+ CC=	/bin/cc
  ED=	-ed
  AS=	-as
diff -rc2N tcsh-6.00.02.orig/config/config.esix4 tcsh-6.00.02/config/config.esix4
*** tcsh-6.00.02.orig/config/config.esix4
--- tcsh-6.00.02/config/config.esix4	Thu Oct 10 20:40:12 1991
***************
*** 0 ****
--- 1,121 ----
+ /*
+  * config.h -- configure various defines for tcsh
+  *
+  * All source files should #include this FIRST.
+  *
+  * Edit this to match your system type.
+  */
+ 
+ /****************** System dependant compilation flags ****************/
+ /*
+  * POSIX	This system supports IEEE Std 1003.1-1988 (POSIX).
+  */
+ #define POSIX
+ 
+ /*
+  * POSIXJOBS	This system supports the optional IEEE Std 1003.1-1988 (POSIX)
+  *		job control facilities.
+  */
+ #define POSIXJOBS
+ 
+ /*
+  * VFORK	This machine has a vfork().  
+  *		It used to be that for job control to work, this define
+  *		was mandatory. This is not the case any more.
+  *		If you think you still need it, but you don't have vfork, 
+  *		define this anyway and then do #define vfork fork.  
+  *		I do this anyway on a Sun because of yellow pages brain damage,
+  *		[should not be needed under 4.1]
+  *		and on the iris4d cause	SGI's fork is sufficiently "virtual" 
+  *		that vfork isn't necessary.  (Besides, SGI's vfork is weird).
+  *		Note that some machines eg. rs6000 have a vfork, but not
+  *		with the berkeley semantics, so we cannot use it there either.
+  *
+  *		For SVR4 this is optional.
+  */
+ #define VFORK
+ 
+ /*
+  * BSDJOBS	You have BSD-style job control (both process groups and
+  *		a tty that deals correctly
+  */
+ #define BSDJOBS
+ 
+ /*
+  * BSDSIGS	You have 4.2-style signals, rather than USG style.
+  *		Note: POSIX systems should not define this unless they
+  *		have sigvec() and friends (ie: 4.3BSD-RENO, HP-UX).
+  */
+ #undef BSDSIGS
+ 
+ /*
+  * BSDTIMES	You have BSD-style process time stuff (like rusage)
+  *		This may or may not be true.  For example, Apple Unix
+  *		(OREO) has BSDJOBS and BSDSIGS but not BSDTIMES.
+  *
+  *		This works with Esix SVR4.  Not sure about DELL SVR4.
+  */
+ #undef BSDTIMES
+ 
+ /*
+  * BSDNICE	Your system uses setpriority() instead of nice, to
+  *		change a processes scheduling priority
+  */
+ #undef BSDNICE
+ 
+ /*
+  * TERMIO	You have struct termio instead of struct sgttyb.
+  * 		This is usually the case for SVID systems, where
+  *		BSD uses sgttyb. POSIX systems should define this
+  *		anyway, even though they use struct termios.
+  */
+ #define TERMIO
+ 
+ /*
+  * SVID		Your machine is SVID complient (Sys V, HPUX, A/UX)
+  *		NOTE: don't do this if you are on a Pyramid -- tcsh is
+  *		built in a BSD universe.
+  *		Set SVID to 1, 2, or 3, depending the version of System V
+  *		you are running. Or set it to 0 if you are not SVID based
+  */
+ #define SVID	4
+ 
+ /*
+  * YPBUGS	Work around Sun YP bugs that cause expansion of ~username
+  *		to send command output to /dev/null
+  */
+ #undef YPBUGS
+ 
+ /*
+  * SIGVOID	Define this if your signal handlers return void.  On older
+  *		systems, signal returns int, but on newer ones, it returns void.
+  */
+ #define SIGVOID 
+ 
+ /*
+  * HAVEDUP2	Define this if your system supports dup2().
+  */
+ #define HAVEDUP2
+ 
+ /*
+  * UTHOST	Does the utmp file have a host field?
+  */
+ #undef UTHOST
+ 
+ /*
+  * DIRENT	Your system has <dirent.h> instead of <sys/dir.h>
+  */
+ #define DIRENT
+ /****************** local defines *********************/
+ 
+ /* Use xgethostname instead, since gethostname is only in libucb.a, and best
+  * not to use that.
+  */
+ 
+ #define gethostname xgethostname
+ 
+ # define NCARGS ARG_MAX
+ 
+ /****************** configurable hacks ****************/
+ /* have been moved to config_f.h */
+ #include "config_f.h"
diff -rc2N tcsh-6.00.02.orig/sh.c tcsh-6.00.02/sh.c
*** tcsh-6.00.02.orig/sh.c	Sat Sep 21 20:10:41 1991
--- tcsh-6.00.02/sh.c	Sat Oct  5 17:41:44 1991
***************
*** 807,811 ****
--- 807,835 ----
      if ((setintr == 0) && (parintr == SIG_DFL))
  	setintr = 1;
+ 
+ /*
+  * SVR4 doesn't send a SIGCHLD when a child is stopped or continued if the
+  * handler is installed with signal(2) or sigset(2).  sigaction(2) must
+  * be used instead.
+  *
+  * David Dawes (dawes@physics.su.oz.au) Sept 1991
+  */
+ 
+ #if SVID > 3
+     {
+ 	struct sigaction act;
+         act.sa_handler=pchild;
+ 	sigemptyset(&(act.sa_mask)); /* Don't block any extra sigs when the
+ 				      * handler is called
+ 				      */
+         act.sa_flags=0;	           /* want behaviour of sigset() without
+                                     * SA_NOCLDSTOP
+ 				    */
+         sigaction(SIGCHLD,&act,(struct sigaction *)NULL);
+     }
+ #else /* SVID <= 3 */
      (void) sigset(SIGCHLD, pchild);	/* while signals not ready */
+ #endif /* SVID <= 3 */
+ 
  
      /*
diff -rc2N tcsh-6.00.02.orig/sh.h tcsh-6.00.02/sh.h
*** tcsh-6.00.02.orig/sh.h	Sat Sep 21 20:10:15 1991
--- tcsh-6.00.02/sh.h	Wed Oct  9 21:12:00 1991
***************
*** 120,124 ****
  #ifdef BSDTIMES
  # include <sys/time.h>
! # include <sys/resource.h>
  #endif /* BSDTIMES */
  
--- 120,128 ----
  #ifdef BSDTIMES
  # include <sys/time.h>
! # if SVID>3
! #  include "/usr/ucbinclude/sys/resource.h"
! # else
! #  include <sys/resource.h>
! # endif /* SVID>3 */
  #endif /* BSDTIMES */
  
diff -rc2N tcsh-6.00.02.orig/sh.init.c tcsh-6.00.02/sh.init.c
*** tcsh-6.00.02.orig/sh.init.c	Sat Sep 21 20:10:16 1991
--- tcsh-6.00.02/sh.init.c	Sat Oct  5 17:41:44 1991
***************
*** 207,211 ****
--- 207,215 ----
  /*  4 */	"ILL",		"Illegal instruction",
  /*  5 */	"TRAP",		"Trace/BPT trap",
+ #if SVID > 3
+ /*  6 */	"ABRT",		"Abort",
+ #else /* SVID > 3 */
  /*  6 */	"IOT",		"IOT trap",
+ #endif /* SVID > 3 */
  #ifdef aiws
  /*  7 */	"DANGER", 	"System Crash Imminent",
***************
*** 302,305 ****
--- 306,333 ----
  # endif /* hpux */
  
+ # if SVID > 3
+ #  define _sigextra_
+ /* 20 */	"WINCH", 	"Window change",
+ /* 21 */	"URG", 		"Urgent socket condition",
+ /* 22 */	"IO", 		"Socket I/O possible",
+ #  ifdef SUSPENDED
+ /* 23 */	"STOP",		"Suspended (signal)",
+ /* 24 */	"TSTP",		"Suspended",
+ /* 25 */	"CONT",		"Continued",
+ /* 26 */	"TTIN", 	"Suspended (tty input)",
+ /* 27 */	"TTOU", 	"Suspended (tty output)",
+ #  else /* SUSPENDED */
+ /* 23 */	"STOP",		"Stopped (signal)",
+ /* 24 */	"TSTP",		"Stopped",
+ /* 25 */	"CONT",		"Continued",
+ /* 26 */	"TTIN", 	"Stopped (tty input)",
+ /* 27 */	"TTOU", 	"Stopped (tty output)",
+ #  endif /* SUSPENDED */
+ /* 28 */	"VTALRM",	"Virtual timer expired",
+ /* 29 */	"PROF",		"Profiling timer expired",
+ /* 30 */	"XCPU",		"CPU time limit exceeded",
+ /* 31 */	"XFSZ", 	"File size limit exceeded",
+ /* 32 */	0,		"Maximum number of signals",
+ # endif /* SVID > 3 */
  # if defined(ISC) && defined(POSIX) 
  #  define _sigextra_
diff -rc2N tcsh-6.00.02.orig/sh.proc.c tcsh-6.00.02/sh.proc.c
*** tcsh-6.00.02.orig/sh.proc.c	Sat Sep 21 20:10:18 1991
--- tcsh-6.00.02/sh.proc.c	Sun Oct  6 15:58:24 1991
***************
*** 973,976 ****
--- 973,984 ----
   * pprint - print a job
   */
+ 
+ /*
+  * Hacks have been added for SVR4 to deal with pipe's being spawned in
+  * reverse order
+  *
+  * David Dawes (dawes@physics.su.oz.au) Oct 1991
+  */
+ 
  static int
  pprint(pp, flag)
***************
*** 984,987 ****
--- 992,1000 ----
      char   *format;
  
+ #if SVID>3
+     struct process *pipehead, *pipetail, *pmarker;
+     int inpipe=0;
+ #endif
+ 
      while (pp->p_pid != pp->p_jobid)
  	pp = pp->p_friends;
***************
*** 994,1000 ****
      jobflags = 0;
      do {
  	jobflags |= pp->p_flags;
  	pstatus = pp->p_flags & PALLSTATES;
! 	if (tp != pp && linp != linbuf && !(flag & FANCY) &&
  	    (pstatus == status && pp->p_reason == reason ||
  	     !(flag & REASON)))
--- 1007,1037 ----
      jobflags = 0;
      do {
+ #if SVID>3
+ 	/*
+ 	 * The pipeline is reversed, so locate the real head of the pipeline
+ 	 * if pp is at the tail of a pipe (and not already in a pipeline
+ 	 */
+ 	if ((pp->p_friends->p_flags & PPOU) && !inpipe && (flag & NAME))
+ 	{
+ 	    inpipe=1;
+ 	    pipetail=pp;
+ 	    do 
+ 		pp=pp->p_friends;
+ 	    while (pp->p_friends->p_flags & PPOU);
+ 	    pipehead=pp;
+ 	    pmarker=pp;
+ 	/*
+ 	 * pmarker is used to hold the place of the proc being processed, so
+ 	 * we can search for the next one downstream later.
+ 	 */
+ 	}
+ #endif /* SVID>3 */	    
  	jobflags |= pp->p_flags;
  	pstatus = pp->p_flags & PALLSTATES;
! 	if ((tp != pp
! #if SVID>3
! 	     || (inpipe && tp == pp)
! #endif /* SVID>3 */
! 	    ) && linp != linbuf && !(flag & FANCY) &&
  	    (pstatus == status && pp->p_reason == reason ||
  	     !(flag & REASON)))
***************
*** 1001,1008 ****
  	    xprintf(" ");
  	else {
! 	    if (tp != pp && linp != linbuf)
  		xprintf("\n");
  	    if (flag & NUMBER)
! 		if (pp == tp)
  		    xprintf("[%d]%s %c ", pp->p_index,
  			    pp->p_index < 10 ? " " : "",
--- 1038,1057 ----
  	    xprintf(" ");
  	else {
! 	    if ((tp != pp 
! #if SVID>3
! 	         || (inpipe && tp == pp)
! #endif /* SVID>3 */
! 		) && linp != linbuf)
  		xprintf("\n");
  	    if (flag & NUMBER)
! 		if ((pp == tp
! #if SVID>3
! 		     && !inpipe
! #endif /* SVID>3 */
! 		    )
! #if SVID>3
! 		     || (inpipe && pipetail == tp && pp == pipehead)
! #endif /* SVID>3 */
! 		   )
  		    xprintf("[%d]%s %c ", pp->p_index,
  			    pp->p_index < 10 ? " " : "",
***************
*** 1119,1123 ****
  
  	}
! 	if (tp == pp->p_friends) {
  	    if (linp != linbuf)
  		xprintf("\n");
--- 1168,1180 ----
  
  	}
! 	if ((tp == pp->p_friends
! #if SVID>3
! 	     && !inpipe
! #endif /* SVID>3 */
! 	    )
! #if SVID>3
! 	     || (inpipe && pipehead->p_friends == tp && pp == pipetail)
! #endif /* SVID>3 */
! 	   ) {
  	    if (linp != linbuf)
  		xprintf("\n");
***************
*** 1128,1132 ****
  	    }
  	}
!     } while ((pp = pp->p_friends) != tp);
      if (jobflags & PTIME && (jobflags & (PSTOPPED | PRUNNING)) == 0) {
  	if (jobflags & NUMBER)
--- 1185,1218 ----
  	    }
  	}
! #if SVID>3
! 	if (inpipe)
! 	{
! 	    /*
! 	     * if pmaker == pipetail, we are finished that pipeline, and
! 	     * can now skip to past the head
! 	     */
! 	    if (pmarker==pipetail)
! 	    {
! 		inpipe=0;
! 		pp=pipehead;
! 	    }
! 	    else
! 	    {
! 	    /*
! 	     * set pp to one before the one we want next, so the while below
! 	     * increments to the correct spot.
! 	     */
! 		do
! 		    pp=pp->p_friends;
! 	    	while (pp->p_friends->p_friends != pmarker);
! 	    	pmarker=pp->p_friends;
! 	    }
! 	}
! #endif /* SVID>3 */
!     } while ((pp = pp->p_friends) != tp
! #if SVID>3
! 	       || inpipe
! #endif /* SVID>3 */
!             );
      if (jobflags & PTIME && (jobflags & (PSTOPPED | PRUNNING)) == 0) {
  	if (jobflags & NUMBER)
***************
*** 1867,1874 ****
      if (wanttty >= 0)
  	if (setpgid(0, pgrp) == -1) {
! #  if !defined(ISC) && !defined(SCO)
  	    /* XXX: Wrong but why? */
  	    xprintf("tcsh: setpgid error (%s).\n", strerror(errno));
  	    xexit(0);
  #  endif /* !ISC && !SCO */
  	}
--- 1953,1972 ----
      if (wanttty >= 0)
  	if (setpgid(0, pgrp) == -1) {
! #  if !defined(ISC) && !defined(SCO) && SVID <= 3
  	    /* XXX: Wrong but why? */
  	    xprintf("tcsh: setpgid error (%s).\n", strerror(errno));
  	    xexit(0);
+ #  elif SVID>3
+ 	    /*
+      	    * This usually happens in svr4 when the last command in a pipe
+ 	    * either couldn't be started, or exits without waiting for input.
+ 	    * Putting in the xexit() hangs the shell, so leave it out.
+ 	    * (DHD)
+      	    */
+ #   ifdef JOBDEBUG
+ 	    xprintf("tcsh: setpgid error (%s).\n", strerror(errno));
+ 	    xprintf("pgrp = %d, shell pid = %d\n",pgrp,getpid());
+ #   endif /* JOBDEBUG */
+ 	    /* xexit(0); */
  #  endif /* !ISC && !SCO */
  	}
diff -rc2N tcsh-6.00.02.orig/sh.sem.c tcsh-6.00.02/sh.sem.c
*** tcsh-6.00.02.orig/sh.sem.c	Sat Sep 21 20:10:20 1991
--- tcsh-6.00.02/sh.sem.c	Sat Oct  5 21:17:16 1991
***************
*** 63,66 ****
--- 63,82 ----
   * C shell
   */
+ 
+ /*
+  * For SVR4, there are problems with pipelines having the first process as
+  * the group leader.  The problem occurs when the first process exits before
+  * the others have a chance to setpgid().  This is because in SVR4 you can't
+  * have a zombie as a group leader.  The solution I have used is to reverse
+  * the order in which pipelines are started, making the last process the
+  * group leader.  (Note I am not using 'pipeline' in the generic sense -- I
+  * mean processes connected by '|'.)  I don't know yet if this causes other
+  * problems.
+  *
+  * All the changes for this are in execute(), and are enclosed in '#if SVID>3'
+  *
+  * David Dawes (dawes@physics.su.oz.au) Oct 1991
+  */
+ 
  /*VARARGS 1*/
  void
***************
*** 109,114 ****
--- 125,135 ----
  
      case NODE_PAREN:
+ #if SVID>3
+ 	if (t->t_dflg & F_PIPEIN)
+ 	    mypipe(pipein);
+ #else /* SVID<=3 */
  	if (t->t_dflg & F_PIPEOUT)
  	    mypipe(pipeout);
+ #endif /* SVID <=3 */
  	/*
  	 * Must do << early so parent will know where input pointer should be.
***************
*** 201,204 ****
--- 222,234 ----
  	 * shell not to change dir!
  	 */
+ #if SVID>3
+ 	/*
+ 	 * Can't have NOFORK for the tail of a pipe - because it is not the
+ 	 * last command spawned (even if it is at the end of a parenthesised
+ 	 * list).
+ 	 */
+ 	if (t->t_dflg & F_PIPEIN)
+ 	    t->t_dflg &= ~(F_NOFORK);
+ #endif /* SVID>3 */
  	if (bifunc && (bifunc->bfunct == dochngd ||
  		       bifunc->bfunct == dopushd ||
***************
*** 463,466 ****
--- 493,502 ----
  	     * express our intentions.
  	     */
+ #if SVID>3
+ 	    if (didfds == 0 && t->t_dflg & F_PIPEOUT) {
+ 		(void) close(pipeout[0]);
+ 		(void) close(pipeout[1]);
+ 	    }
+ #else /* SVID <=3 */
  	    if (didfds == 0 && t->t_dflg & F_PIPEIN) {
  		(void) close(pipein[0]);
***************
*** 467,471 ****
  		(void) close(pipein[1]);
  	    }
! 	    if ((t->t_dflg & F_PIPEOUT) == 0) {
  		if (nosigchld) {
  #ifdef BSDSIGS
--- 503,514 ----
  		(void) close(pipein[1]);
  	    }
! #endif /* SVID<=3 */
! 	    if ((t->t_dflg &
! #if SVID>3
! 	      F_PIPEIN
! #else /* SVID<=3 */
! 	      F_PIPEOUT
! #endif /* SVID<=3 */
! 	       ) == 0) {
  		if (nosigchld) {
  #ifdef BSDSIGS
***************
*** 481,484 ****
--- 524,534 ----
  	    break;
  	}
+ #if SVID>3
+ 	doio(t, pipein, pipeout);
+ 	if (t->t_dflg & F_PIPEIN) {
+ 	    (void) close(pipein[0]);
+ 	    (void) close(pipein[1]);
+ 	}
+ #else /* SVID<=3 */
  	doio(t, pipein, pipeout);
  	if (t->t_dflg & F_PIPEOUT) {
***************
*** 486,489 ****
--- 536,540 ----
  	    (void) close(pipeout[1]);
  	}
+ #endif /* SVID<=3 */
  	/*
  	 * Perform a builtin function. If we are not forked, arrange for
***************
*** 520,523 ****
--- 571,584 ----
  
      case NODE_PIPE:
+ #if SVID>3
+ 	t->t_dcdr->t_dflg |= F_PIPEIN | (t->t_dflg &
+ 			(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT));
+ 	execute(t->t_dcdr, wanttty, pv, pipeout);
+ 	t->t_dcar->t_dflg |= F_PIPEOUT |
+ 	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT));
+ 	if (wanttty > 0)
+ 	    wanttty = 0;	/* got tty already */
+ 	execute(t->t_dcar, wanttty, pipein, pv);
+ #else /* SVID<=3 */
  	t->t_dcar->t_dflg |= F_PIPEOUT |
  	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT));
***************
*** 528,531 ****
--- 589,593 ----
  	    wanttty = 0;	/* got tty already */
  	execute(t->t_dcdr, wanttty, pv, pipeout);
+ #endif /* SVID<=3 */
  	break;
  
