1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix crash in backtick comsubs with job control on (rhbz#825520)

This imports another fix from Red Hat/Fedora. Original patch:
642af4d6/f/ksh-20120801-crash.patch

src/cmd/ksh93/include/jobs.h,
src/cmd/ksh93/sh/jobs.c,
src/cmd/ksh93/sh/subshell.c,
src/cmd/ksh93/sh/xec.c:
- Import the Red Hat fix with these differences:
  - Rename the 'hack1_waitall' variable to 'bktick_waitall' and add
    a comment describing what it's for.
  - Remove unused 'pipefail' variable.

src/cmd/ksh93/tests/basic.sh:
- Regression test from reproducer given in the Red Hat bug report.
- Add special handling to SIGKILL it, as it might freeze hard.
This commit is contained in:
Martijn Dekker 2020-09-23 01:56:09 +02:00
parent f7ffaaba17
commit ce68e1be37
7 changed files with 32 additions and 3 deletions

View file

@ -1803,6 +1803,7 @@ again:
{
count = bp->count;
jp = bp->list;
jpold = 0;
goto again;
}
if(jp)

View file

@ -524,7 +524,10 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_t *t, volatile int flags, int comsub)
sp->comsub = shp->comsub;
shp->subshare = comsub==2 || (comsub==1 && sh_isoption(SH_SUBSHARE));
if(comsub)
{
shp->comsub = comsub;
job.bktick_waitall = (comsub==1);
}
if(!comsub || !shp->subshare)
{
struct subshell *xp;
@ -655,6 +658,7 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_t *t, volatile int flags, int comsub)
}
else
{
job.bktick_waitall = 0;
if(comsub!=1 && shp->spid)
{
job_wait(shp->spid);

View file

@ -1927,7 +1927,7 @@ int sh_exec(register const Shnode_t *t, int flags)
memset(exitval,0,job.waitall*sizeof(int));
}
else
job.waitall |= !pipejob && sh_isstate(SH_MONITOR);
job.waitall |= (job.bktick_waitall || !pipejob && sh_isstate(SH_MONITOR));
job_lock();
nlock++;
do