mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix ${ comsub; } killing job control
Another longstanding whopper of a bug in basic ksh93 functionality:
run a ${ shared-state; } command substitution twice and job control
promptly loses track of all your running jobs. New jobs are tracked
again until you run another two shared-state command substitutions.
This is in at least 93t+, 93u-, 93u+, 93v- and ksh2020.
$ sleep 300 &
[1] 56883
$ jobs # OK
[1] + Running sleep 300 &
$ v=${ echo hi1; }
$ jobs # OK
[1] + Running sleep 300 &
$ v=${ echo hi2; }
$ jobs # Nothing!
$ fg
ksh: fg: no such job
src/cmd/ksh93/sh/subshell.c: sh_subshell():
- The current environment number shp->curenv (a.k.a. sh.curenv) was
not being restored if the virtual subshell we're leaving is of
the shared-state command substitution variety as it was wrongly
considered to be part of the environment that didn't need
restoring. This caused it to be out of sync with shp->jobenv
(a.k.a. sh.jobenv) which did get restored from savedcurenv.
Restore both from savedcurenv at the same time for any subshell.
(How these numbers are used exactly remains to be discovered.)
src/cmd/ksh93/tests/jobs.sh:
- Added, with a test for this bug to start it off. There is no
other test script where job control fits, and a lot more related
fixes are anticipated: https://github.com/ksh93/ksh/issues/119
This commit is contained in:
parent
2996d7ae7c
commit
37a18bab71
4 changed files with 51 additions and 3 deletions
|
|
@ -752,7 +752,7 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_t *t, volatile int flags, int comsub)
|
|||
path_delete((Pathcomp_t*)shp->pathlist);
|
||||
shp->pathlist = (void*)sp->pathlist;
|
||||
job_subrestore(sp->jobs);
|
||||
shp->jobenv = savecurenv;
|
||||
shp->curenv = shp->jobenv = savecurenv;
|
||||
job.curpgid = savejobpgid;
|
||||
job.exitval = saveexitval;
|
||||
shp->bckpid = sp->bckpid;
|
||||
|
|
@ -794,7 +794,6 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_t *t, volatile int flags, int comsub)
|
|||
if(n>0)
|
||||
memset(&shp->st.trapcom[savst.trapmax],0,n*sizeof(char*));
|
||||
shp->st = savst;
|
||||
shp->curenv = savecurenv;
|
||||
shp->st.otrap = 0;
|
||||
if(nsig)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue