mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 10:21:46 +02:00
43464: Another attachtty() fix.
If list_pipe_job triggered more than once we need to know the most recent process group leader, so record that both if the attach happened in the main shell on in entersubsh(). Also don't pass back proocess group for ESUB_ASYNC subshells.
This commit is contained in:
parent
301ca1229a
commit
551ff84272
5 changed files with 31 additions and 8 deletions
|
@ -1,3 +1,10 @@
|
|||
2018-09-16 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 43464: Src/exec.c, Src/jobs.c, Src/signals.c, Src/utils.c:
|
||||
Remember the last process group to attach to the terminal, not
|
||||
just the set of running processes which did. Don't
|
||||
record process groups for ESUB_ASYNC subshells.
|
||||
|
||||
2018-09-14 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* unposted: Completion/Unix/Command/_subversion: _svn: Allow
|
||||
|
|
13
Src/exec.c
13
Src/exec.c
|
@ -1036,7 +1036,7 @@ entersubsh(int flags, struct entersubsh_ret *retp)
|
|||
if (!(flags & ESUB_ASYNC))
|
||||
attachtty(jobtab[thisjob].gleader);
|
||||
}
|
||||
if (retp) {
|
||||
if (retp && !(flags & ESUB_ASYNC)) {
|
||||
retp->gleader = jobtab[list_pipe_job].gleader;
|
||||
retp->list_pipe_job = list_pipe_job;
|
||||
}
|
||||
|
@ -1058,12 +1058,13 @@ entersubsh(int flags, struct entersubsh_ret *retp)
|
|||
!jobtab[list_pipe_job].gleader)
|
||||
jobtab[list_pipe_job].gleader = jobtab[thisjob].gleader;
|
||||
setpgrp(0L, jobtab[thisjob].gleader);
|
||||
if (!(flags & ESUB_ASYNC))
|
||||
if (!(flags & ESUB_ASYNC)) {
|
||||
attachtty(jobtab[thisjob].gleader);
|
||||
if (retp) {
|
||||
retp->gleader = jobtab[thisjob].gleader;
|
||||
if (list_pipe_job != thisjob)
|
||||
retp->list_pipe_job = list_pipe_job;
|
||||
if (retp) {
|
||||
retp->gleader = jobtab[thisjob].gleader;
|
||||
if (list_pipe_job != thisjob)
|
||||
retp->list_pipe_job = list_pipe_job;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
Src/jobs.c
10
Src/jobs.c
|
@ -40,6 +40,11 @@ mod_export pid_t origpgrp;
|
|||
|
||||
/**/
|
||||
mod_export pid_t mypgrp;
|
||||
|
||||
/* the last process group to attach to the terminal */
|
||||
|
||||
/**/
|
||||
pid_t last_attached_pgrp;
|
||||
|
||||
/* the job we are working on */
|
||||
|
||||
|
@ -1405,6 +1410,11 @@ addproc(pid_t pid, char *text, int aux, struct timeval *bgtime,
|
|||
jobtab[thisjob].gleader = gleader;
|
||||
if (list_pipe_job_used != -1)
|
||||
jobtab[list_pipe_job_used].gleader = gleader;
|
||||
/*
|
||||
* Record here this is the latest process group to grab the
|
||||
* terminal as attachtty() was run in the subshell.
|
||||
*/
|
||||
last_attached_pgrp = gleader;
|
||||
} else if (!jobtab[thisjob].gleader)
|
||||
jobtab[thisjob].gleader = pid;
|
||||
/* attach this process to end of process list of current job */
|
||||
|
|
|
@ -540,8 +540,8 @@ wait_for_processes(void)
|
|||
if (WIFEXITED(status) &&
|
||||
pn->pid == jn->gleader &&
|
||||
killpg(pn->pid, 0) == -1) {
|
||||
jn->gleader = 0;
|
||||
if (!(jn->stat & STAT_NOSTTY)) {
|
||||
if (last_attached_pgrp == jn->gleader &&
|
||||
!(jn->stat & STAT_NOSTTY)) {
|
||||
/*
|
||||
* This PID was in control of the terminal;
|
||||
* reclaim terminal now it has exited.
|
||||
|
@ -552,6 +552,7 @@ wait_for_processes(void)
|
|||
attachtty(mypgrp);
|
||||
adjustwinsize(0);
|
||||
}
|
||||
jn->gleader = 0;
|
||||
}
|
||||
}
|
||||
update_job(jn);
|
||||
|
|
|
@ -4670,6 +4670,10 @@ attachtty(pid_t pgrp)
|
|||
ep = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
last_attached_pgrp = pgrp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue