ebf9b31
diff -up ksh-20120801/src/cmd/ksh93/include/jobs.h.crash ksh-20120801/src/cmd/ksh93/include/jobs.h
d92eec9
--- ksh-20120801/src/cmd/ksh93/include/jobs.h.crash	2014-07-16 17:32:03.570057304 +0200
d92eec9
+++ ksh-20120801/src/cmd/ksh93/include/jobs.h	2014-07-16 17:32:03.600057172 +0200
ebf9b31
@@ -118,6 +118,7 @@ struct jobs
ebf9b31
 	char		jobcontrol;	/* turned on for real job control */
ebf9b31
 	char		waitsafe;	/* wait will not block */
ebf9b31
 	char		waitall;	/* wait for all jobs in pipe */
ebf9b31
+	char		hack1_waitall;
ebf9b31
 	char		toclear;	/* job table needs clearing */
ebf9b31
 	unsigned char	*freejobs;	/* free jobs numbers */
ebf9b31
 #if SHOPT_COSHELL
ebf9b31
diff -up ksh-20120801/src/cmd/ksh93/sh/jobs.c.crash ksh-20120801/src/cmd/ksh93/sh/jobs.c
d92eec9
--- ksh-20120801/src/cmd/ksh93/sh/jobs.c.crash	2014-07-16 17:32:03.554057375 +0200
d92eec9
+++ ksh-20120801/src/cmd/ksh93/sh/jobs.c	2014-07-16 17:32:03.600057172 +0200
ebf9b31
@@ -1957,6 +1957,7 @@ again:
ebf9b31
 	{
ebf9b31
 		count = bp->count;
ebf9b31
 		jp = bp->list;
ebf9b31
+		jpold = 0;
ebf9b31
 		goto again;
ebf9b31
 	}
ebf9b31
 	if(jp)
ebf9b31
diff -up ksh-20120801/src/cmd/ksh93/sh/subshell.c.crash ksh-20120801/src/cmd/ksh93/sh/subshell.c
d92eec9
--- ksh-20120801/src/cmd/ksh93/sh/subshell.c.crash	2014-07-16 17:32:03.593057203 +0200
d92eec9
+++ ksh-20120801/src/cmd/ksh93/sh/subshell.c	2014-07-16 17:32:03.600057172 +0200
ebf9b31
@@ -492,6 +492,7 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
ebf9b31
 	struct sh_scoped savst;
ebf9b31
 	struct dolnod   *argsav=0;
ebf9b31
 	int argcnt;
ebf9b31
+        int pipefail = 0;
ebf9b31
 	memset((char*)sp, 0, sizeof(*sp));
ebf9b31
 	sfsync(shp->outpool);
ebf9b31
 	sh_sigcheck(shp);
ebf9b31
@@ -541,7 +542,10 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
ebf9b31
 	sp->comsub = shp->comsub;
ebf9b31
 	shp->subshare = comsub==2 ||  (comsub==1 && sh_isoption(SH_SUBSHARE));
ebf9b31
 	if(comsub)
ebf9b31
+	{
ebf9b31
 		shp->comsub = comsub;
ebf9b31
+		job.hack1_waitall=(comsub==1);
ebf9b31
+	}
ebf9b31
 	sp->shpwdfd=-1;
ebf9b31
 	if(!comsub || !shp->subshare)
ebf9b31
 	{
ebf9b31
@@ -648,6 +652,7 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
ebf9b31
 		}
ebf9b31
 		else
ebf9b31
 		{
ebf9b31
+			job.hack1_waitall=0;
d92eec9
 			/* move tmp file to iop and restore sfstdout */
d92eec9
 			iop = sfswap(sfstdout,NIL(Sfio_t*));
d92eec9
 			if(!iop)
ebf9b31
diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.crash ksh-20120801/src/cmd/ksh93/sh/xec.c
d92eec9
--- ksh-20120801/src/cmd/ksh93/sh/xec.c.crash	2014-07-16 17:32:03.587057230 +0200
d92eec9
+++ ksh-20120801/src/cmd/ksh93/sh/xec.c	2014-07-16 17:32:03.601057168 +0200
ebf9b31
@@ -2125,7 +2125,7 @@ int sh_exec(register const Shnode_t *t,
ebf9b31
 				memset(exitval,0,job.waitall*sizeof(int));
ebf9b31
 			}
ebf9b31
 			else
ebf9b31
-				job.waitall |= !pipejob && sh_isstate(SH_MONITOR);
ebf9b31
+				job.waitall |= job.hack1_waitall || !pipejob && sh_isstate(SH_MONITOR);
ebf9b31
 			job_lock();
ebf9b31
 			nlock++;
ebf9b31
 			do