mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix hang in comsubs
(rhbz#1062296) (re: 970069a6
)
The new command substitution mechanism imported in970069a6
from Red Hat patches introduced this bug: backtick-style command substitutions hang when processing about 117KiB of data or more. It is fixed by another Red Hat patch:642af4d6/f/ksh-20140415-hokaido.patch
It saves the value of the shp->comsub flag so that it is set to 2 (usually meaning new-style $(comsubs)) in two specific cases even when processing backtick comsubs. This stops the sh_subtmpfile() function in subshell.c from creating a /tmp file. However, I think that approach is quite ugly, so I'm taking a slightly different one that has the same effect. src/cmd/ksh93/include/defs.h, src/cmd/ksh93/sh/subshell.c: - Redefine sh_subtmpfile() to pass the comsub flag as an argument. (Remove the shp pointer argument, which is redundant; a pointer to the shell state can easily be obtained in the function.) src/cmd/ksh93/sh/xec.c: sh_exec(): - Apply the Red Hat fix by passing flag 2 to sh_subtmpfile(). src/cmd/ksh93/tests/subshell.sh: - Move regress test fromce68e1be
from basic.sh to here; this is the place for command substitution tests as they are subshells. - Add regress test for this bug. All other changed files: - Update sh_subtmpfile() calls to pass on the shp->comsub flag.
This commit is contained in:
parent
3654ee73c0
commit
4ce486a7a4
7 changed files with 42 additions and 30 deletions
|
@ -1319,7 +1319,7 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
bp->notify = 0;
|
||||
bp->flags = (OPTIMIZE!=0);
|
||||
if(shp->subshell && nv_isattr(np,BLT_NOSFIO))
|
||||
sh_subtmpfile(shp);
|
||||
sh_subtmpfile(shp->comsub);
|
||||
if(execflg && !shp->subshell &&
|
||||
!shp->st.trapcom[0] && !shp->st.trap[SH_ERRTRAP] && shp->fn_depth==0 && !nv_isattr(np,BLT_ENV))
|
||||
{
|
||||
|
@ -1527,10 +1527,12 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
int pipes[3];
|
||||
if(shp->subshell)
|
||||
{
|
||||
sh_subtmpfile(shp);
|
||||
sh_subtmpfile(2);
|
||||
if(shp->comsub==1 && (!(shp->fdstatus[1]&IONOSEEK)))
|
||||
unpipe = iousepipe(shp);
|
||||
if((type&(FAMP|TFORK))==(FAMP|TFORK))
|
||||
{
|
||||
if(shp->comsub && !(shp->fdstatus[1]&IONOSEEK))
|
||||
if(shp->comsub && !(shp->fdstatus[1]&IONOSEEK) && !unpipe)
|
||||
unpipe = iousepipe(shp);
|
||||
sh_subfork();
|
||||
}
|
||||
|
@ -1909,7 +1911,7 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
job.curjobid = 0;
|
||||
if(shp->subshell)
|
||||
{
|
||||
sh_subtmpfile(shp);
|
||||
sh_subtmpfile(2);
|
||||
if(shp->comsub==1 && !(shp->fdstatus[1]&IONOSEEK))
|
||||
iousepipe(shp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue