mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-10 08:01:41 +01:00
29677: Do not allow external processes in a pipeline to become suspended
when the end of the pipe is controlled by a builtin in the current shell which cannot itself become suspended.
This commit is contained in:
parent
8af2cbd1f2
commit
516ea294b8
4 changed files with 24 additions and 6 deletions
|
@ -11,6 +11,13 @@
|
||||||
* unposted: Src/jobs.c: fix capitalized word in the middle of
|
* unposted: Src/jobs.c: fix capitalized word in the middle of
|
||||||
a sentence.
|
a sentence.
|
||||||
|
|
||||||
|
2011-08-14 Barton E. Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 29677: Src/exec.c, Src/signals.c, Src/zsh.h: flag jobs that are
|
||||||
|
builtins running in the current shell, and if they control a
|
||||||
|
pipeline, do not allow the external processes in that pipeline to
|
||||||
|
become suspended when the foreground shell cannot suspend.
|
||||||
|
|
||||||
2011-08-11 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2011-08-11 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* Src/Modules/datetime.mdd: unposted: also fix the autofeatures.
|
* Src/Modules/datetime.mdd: unposted: also fix the autofeatures.
|
||||||
|
@ -15247,5 +15254,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5426 $
|
* $Revision: 1.5427 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -2848,6 +2848,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
|
||||||
jobtab[thisjob].stat |= STAT_CURSH;
|
jobtab[thisjob].stat |= STAT_CURSH;
|
||||||
if (!jobtab[thisjob].procs)
|
if (!jobtab[thisjob].procs)
|
||||||
jobtab[thisjob].stat |= STAT_NOPRINT;
|
jobtab[thisjob].stat |= STAT_NOPRINT;
|
||||||
|
if (is_builtin)
|
||||||
|
jobtab[thisjob].stat |= STAT_BUILTIN;
|
||||||
} else {
|
} else {
|
||||||
/* This is an exec (real or fake) for an external command. *
|
/* This is an exec (real or fake) for an external command. *
|
||||||
* Note that any form of exec means that the subshell is fake *
|
* Note that any form of exec means that the subshell is fake *
|
||||||
|
|
|
@ -490,14 +490,21 @@ wait_for_processes(void)
|
||||||
* update it.
|
* update it.
|
||||||
*/
|
*/
|
||||||
if (findproc(pid, &jn, &pn, 0)) {
|
if (findproc(pid, &jn, &pn, 0)) {
|
||||||
|
if (((jn->stat & STAT_BUILTIN) ||
|
||||||
|
(list_pipe && (jobtab[thisjob].stat & STAT_BUILTIN))) &&
|
||||||
|
WIFSTOPPED(status) && WSTOPSIG(status) == SIGTSTP) {
|
||||||
|
killjb(jn, SIGCONT);
|
||||||
|
zwarn("job can't be suspended");
|
||||||
|
} else {
|
||||||
#if defined(HAVE_WAIT3) && defined(HAVE_GETRUSAGE)
|
#if defined(HAVE_WAIT3) && defined(HAVE_GETRUSAGE)
|
||||||
struct timezone dummy_tz;
|
struct timezone dummy_tz;
|
||||||
gettimeofday(&pn->endtime, &dummy_tz);
|
gettimeofday(&pn->endtime, &dummy_tz);
|
||||||
pn->status = status;
|
pn->status = status;
|
||||||
pn->ti = ru;
|
pn->ti = ru;
|
||||||
#else
|
#else
|
||||||
update_process(pn, status);
|
update_process(pn, status);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
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;
|
||||||
|
|
|
@ -907,6 +907,8 @@ struct job {
|
||||||
#define STAT_ATTACH (0x1000) /* delay reattaching shell to tty */
|
#define STAT_ATTACH (0x1000) /* delay reattaching shell to tty */
|
||||||
#define STAT_SUBLEADER (0x2000) /* is super-job, but leader is sub-shell */
|
#define STAT_SUBLEADER (0x2000) /* is super-job, but leader is sub-shell */
|
||||||
|
|
||||||
|
#define STAT_BUILTIN (0x4000) /* job at tail of pipeline is a builtin */
|
||||||
|
|
||||||
#define SP_RUNNING -1 /* fake status for jobs currently running */
|
#define SP_RUNNING -1 /* fake status for jobs currently running */
|
||||||
|
|
||||||
struct timeinfo {
|
struct timeinfo {
|
||||||
|
|
Loading…
Reference in a new issue