mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-08 18:18:02 +02:00
52365: record state of exited background jobs so as to be visible in TRAPCHLD
This commit is contained in:
parent
618f842b46
commit
0ecc456fb2
3 changed files with 27 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2023-12-09 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 52365: Src/jobs.c, Src/signals.c: record state of exited
|
||||||
|
background jobs sooner so as to be visible in TRAPCHLD
|
||||||
|
|
||||||
2023-12-05 Oliver Kiddle <opk@zsh.org>
|
2023-12-05 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
* 52326, 52372: configure.ac, Src/jobs.c, Doc/Zsh/builtins.yo,
|
* 52326, 52372: configure.ac, Src/jobs.c, Doc/Zsh/builtins.yo,
|
||||||
|
|
19
Src/jobs.c
19
Src/jobs.c
|
@ -660,6 +660,25 @@ update_job(Job jn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
void
|
||||||
|
update_bg_job(Job jn, pid_t pid, int status)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Accumulate a list of older jobs. We only do this for
|
||||||
|
* background jobs, which is something in the job table
|
||||||
|
* that's not marked as in the current shell or as shell builtin
|
||||||
|
* and is not equal to the current foreground job.
|
||||||
|
*/
|
||||||
|
if (jn && !(jn->stat & (STAT_CURSH|STAT_BUILTIN)) &&
|
||||||
|
jn - jobtab != thisjob) {
|
||||||
|
if (WIFEXITED(status))
|
||||||
|
addbgstatus(pid, WEXITSTATUS(status));
|
||||||
|
else if (WIFSIGNALED(status))
|
||||||
|
addbgstatus(pid, 0200 | WTERMSIG(status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set the previous job to something reasonable */
|
/* set the previous job to something reasonable */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
|
@ -556,9 +556,11 @@ wait_for_processes(void)
|
||||||
jn->gleader = 0;
|
jn->gleader = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
update_bg_job(jn, pid, status);
|
||||||
update_job(jn);
|
update_job(jn);
|
||||||
} else if (findproc(pid, &jn, &pn, 1)) {
|
} else if (findproc(pid, &jn, &pn, 1)) {
|
||||||
pn->status = status;
|
pn->status = status;
|
||||||
|
update_bg_job(jn, pid, status);
|
||||||
update_job(jn);
|
update_job(jn);
|
||||||
} else {
|
} else {
|
||||||
/* If not found, update the shell record of time spent by
|
/* If not found, update the shell record of time spent by
|
||||||
|
@ -567,19 +569,7 @@ wait_for_processes(void)
|
||||||
* terminates.
|
* terminates.
|
||||||
*/
|
*/
|
||||||
get_usage();
|
get_usage();
|
||||||
}
|
update_bg_job(jn, pid, status);
|
||||||
/*
|
|
||||||
* Accumulate a list of older jobs. We only do this for
|
|
||||||
* background jobs, which is something in the job table
|
|
||||||
* that's not marked as in the current shell or as shell builtin
|
|
||||||
* and is not equal to the current foreground job.
|
|
||||||
*/
|
|
||||||
if (jn && !(jn->stat & (STAT_CURSH|STAT_BUILTIN)) &&
|
|
||||||
jn - jobtab != thisjob) {
|
|
||||||
if (WIFEXITED(status))
|
|
||||||
addbgstatus(pid, WEXITSTATUS(status));
|
|
||||||
else if (WIFSIGNALED(status))
|
|
||||||
addbgstatus(pid, 0200 | WTERMSIG(status));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unqueue_signals();
|
unqueue_signals();
|
||||||
|
|
Loading…
Reference in a new issue