Blame SOURCES/ksh-20120801-fd2lost.patch

1a53a7
diff -up ksh-20120801/src/cmd/ksh93/sh/macro.c.fd2lost ksh-20120801/src/cmd/ksh93/sh/macro.c
1a53a7
--- ksh-20120801/src/cmd/ksh93/sh/macro.c.fd2lost	2014-01-22 16:23:21.211658984 +0100
1a53a7
+++ ksh-20120801/src/cmd/ksh93/sh/macro.c	2014-01-22 16:23:21.243658703 +0100
1a53a7
@@ -391,7 +391,7 @@ void sh_machere(Shell_t *shp,Sfio_t *inf
1a53a7
 				break;
1a53a7
 			    }
1a53a7
 			    case S_PAR:
1a53a7
-				comsubst(mp,(Shnode_t*)0,1);
1a53a7
+				comsubst(mp,(Shnode_t*)0,3);
1a53a7
 				break;
1a53a7
 			    case S_EOF:
1a53a7
 				if((c=fcfill()) > 0)
1a53a7
@@ -1165,7 +1165,7 @@ retry1:
1a53a7
 	    case S_PAR:
1a53a7
 		if(type)
1a53a7
 			goto nosub;
1a53a7
-		comsubst(mp,(Shnode_t*)0,1);
1a53a7
+		comsubst(mp,(Shnode_t*)0,3);
1a53a7
 		return(1);
1a53a7
 	    case S_DIG:
1a53a7
 		var = 0;
1a53a7
diff -up ksh-20120801/src/cmd/ksh93/sh/subshell.c.fd2lost ksh-20120801/src/cmd/ksh93/sh/subshell.c
1a53a7
--- ksh-20120801/src/cmd/ksh93/sh/subshell.c.fd2lost	2014-01-22 16:23:21.222658887 +0100
1a53a7
+++ ksh-20120801/src/cmd/ksh93/sh/subshell.c	2014-01-22 16:23:21.243658703 +0100
1a53a7
@@ -122,7 +122,8 @@ void	sh_subtmpfile(Shell_t *shp)
1a53a7
 		else if(errno!=EBADF)
1a53a7
 			errormsg(SH_DICT,ERROR_system(1),e_toomany);
1a53a7
 		/* popping a discipline forces a /tmp file create */
1a53a7
-		sfdisc(sfstdout,SF_POPDISC);
1a53a7
+		if(shp->comsub != 1)
1a53a7
+			sfdisc(sfstdout,SF_POPDISC);
1a53a7
 		if((fd=sffileno(sfstdout))<0)
1a53a7
 		{
1a53a7
 			/* unable to create the /tmp file so use a pipe */
1a53a7
@@ -635,6 +636,13 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
1a53a7
 		}
1a53a7
 		else
1a53a7
 		{
1a53a7
+			if(comsub!=1 && shp->spid)
1a53a7
+			{
1a53a7
+				job_wait(shp->spid);
1a53a7
+				if(shp->pipepid==shp->spid)
1a53a7
+					shp->spid = 0;
1a53a7
+				shp->pipepid = 0;
1a53a7
+			}
1a53a7
 			/* move tmp file to iop and restore sfstdout */
1a53a7
 			iop = sfswap(sfstdout,NIL(Sfio_t*));
1a53a7
 			if(!iop)
1a53a7
diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.fd2lost ksh-20120801/src/cmd/ksh93/sh/xec.c
1a53a7
--- ksh-20120801/src/cmd/ksh93/sh/xec.c.fd2lost	2014-01-22 16:23:21.237658756 +0100
1a53a7
+++ ksh-20120801/src/cmd/ksh93/sh/xec.c	2014-01-22 16:38:36.374666019 +0100
1a53a7
@@ -1756,6 +1756,8 @@ int sh_exec(register const Shnode_t *t,
1a53a7
 					nlock--;
1a53a7
 					job_unlock();
1a53a7
 				}
1a53a7
+				if(shp->subshell)
1a53a7
+					shp->spid = parent;
1a53a7
 				if(type&FPCL)
1a53a7
 					sh_close(shp->inpipe[0]);
1a53a7
 				if(type&(FCOOP|FAMP))
1a53a7
@@ -1771,7 +1773,11 @@ int sh_exec(register const Shnode_t *t,
1a53a7
 					if(shp->pipepid)
1a53a7
 						shp->pipepid = parent;
1a53a7
 					else
1a53a7
+					{
1a53a7
 						job_wait(parent);
1a53a7
+						if(parent==shp->spid)
1a53a7
+							shp->spid = 0;
1a53a7
+					}
1a53a7
 					if(shp->topfd > topfd)
1a53a7
 						sh_iorestore(shp,topfd,0);
1a53a7
 					if(usepipe && tsetio &&  subdup && unpipe)