Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 7445888659893398b01d014bc633b458 > files > 43

ksh-20100621-18.el5.src.rpm

diff -pruN ksh-20100811/src/cmd/ksh93/sh/xec.c ksh-20101010/src/cmd/ksh93/sh/xec.c
--- ksh-20100811/src/cmd/ksh93/sh/xec.c	2010-08-06 20:46:07.000000000 +0530
+++ ksh-20101010/src/cmd/ksh93/sh/xec.c	2010-10-09 01:20:21.000000000 +0530
@@ -86,7 +87,7 @@ struct funenv
  * temp file.
  */
 static int	subpipe[3] = {-1};
-static int	subdup;
+static int	subdup,tsetio;
 static void iousepipe(Shell_t *shp)
 {
 	int i;
@@ -135,6 +136,7 @@ static void iounpipe(Shell_t *shp)
 	}
 	sh_close(subpipe[0]);
 	subpipe[0] = -1;
+	tsetio = 0;
 }
 
 /*
@@ -1534,6 +1547,8 @@ int sh_exec(register const Shnode_t *t,
 						shp->pipepid = parent;
 					else
 						job_wait(parent);
+					if(tsetio &&  subdup)
+						iounpipe(shp);
 					if(!sh_isoption(SH_MONITOR))
 					{
 						shp->trapnote &= ~SH_SIGIGNORE;
@@ -1697,6 +1712,8 @@ int sh_exec(register const Shnode_t *t,
 			jmpval = sigsetjmp(buff.buff,0);
 			if(jmpval==0)
 			{
+				if(shp->comsub==1)
+					tsetio = 1;
 				sh_redirect(shp,t->fork.forkio,execflg);
 				(t->fork.forktre)->tre.tretyp |= t->tre.tretyp&FSHOWME;
 				sh_exec(t->fork.forktre,flags&~simple);
@@ -2897,7 +2921,10 @@ pid_t _sh_fork(Shell_t *shp,register pid
 		if(jobid)
 			*jobid = myjob;
 		if(shp->comsub==1 && subpipe[0]>=0)
-			iounpipe(shp);
+		{
+			if(!tsetio || !subdup)
+				iounpipe(shp);
+		}
 		return(parent);
 	}
 #if !_std_malloc