bc9e18
diff -up ksh-20140415/src/cmd/ksh93/sh/subshell.c.hokaido ksh-20140415/src/cmd/ksh93/sh/subshell.c
bc9e18
diff -up ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido ksh-20140415/src/cmd/ksh93/sh/xec.c
bc9e18
--- ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido	2014-03-17 22:13:55.000000000 +0100
bc9e18
+++ ksh-20140415/src/cmd/ksh93/sh/xec.c	2014-05-20 18:23:49.712532290 +0200
bc9e18
@@ -1630,12 +1630,20 @@ tryagain:
bc9e18
 #endif /* SHOPT_COSHELL */
bc9e18
 			if(shp->subshell)
bc9e18
 			{
bc9e18
+				int comsubsave = shp->comsub;
bc9e18
+				if(comsubsave==1)
bc9e18
+					shp->comsub = 2;
bc9e18
 				sh_subtmpfile(shp);
bc9e18
+				shp->comsub = comsubsave;
bc9e18
+				if(shp->comsub==1 && !(shp->fdstatus[1]&IONOSEEK))
bc9e18
+					unpipe = iousepipe(shp);
bc9e18
+
bc9e18
 				if((type&(FAMP|TFORK))==(FAMP|TFORK))
bc9e18
 				{
bc9e18
 					if(shp->comsub && !(shp->fdstatus[1]&IONOSEEK))
bc9e18
 					{
bc9e18
-						unpipe = iousepipe(shp);
bc9e18
+						if (!unpipe)
bc9e18
+							unpipe = iousepipe(shp);
bc9e18
 						sh_subfork();
bc9e18
 					}
bc9e18
 				}