3b3638
diff -up ksh-20120801/src/cmd/ksh93/sh/subshell.c.retfix ksh-20120801/src/cmd/ksh93/sh/subshell.c
b84729
--- ksh-20120801/src/cmd/ksh93/sh/subshell.c.retfix	2014-10-01 17:34:47.720532950 +0200
b84729
+++ ksh-20120801/src/cmd/ksh93/sh/subshell.c	2014-10-01 17:35:25.850350378 +0200
b84729
@@ -655,7 +655,10 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
b84729
 			job.hack1_waitall=0;
b84729
 			if(comsub!=1 && shp->spid)
b84729
 			{
3b3638
+				int c = shp->exitval;
b84729
 				job_wait(shp->spid);
3b3638
+				shp->exitval = c;
3b3638
+				exitset();
b84729
 				if(shp->pipepid==shp->spid)
b84729
 					shp->spid = 0;
b84729
 				shp->pipepid = 0;