From 98b29d02ca17068779f4b8fa2d43c9753386478f Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Wed, 15 Jun 2011 15:38:14 +0000 Subject: 29481: always return a matching job in findproc() but scan the whole list to prefer running jobs --- Src/signals.c | 1 - 1 file changed, 1 deletion(-) (limited to 'Src/signals.c') diff --git a/Src/signals.c b/Src/signals.c index 456a85300..a848acdbe 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -489,7 +489,6 @@ wait_for_processes(void) * Find the process and job containing this pid and * update it. */ - pn = NULL; if (findproc(pid, &jn, &pn, 0)) { #if defined(HAVE_WAIT3) && defined(HAVE_GETRUSAGE) struct timezone dummy_tz; -- cgit v1.2.3 From a3ae9f5d126ee235301322d3ee370e6b2235090c Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 4 Aug 2011 08:30:50 +0000 Subject: 29643: set incompfunc to zero when executing hook or trap function --- Src/Zle/zle_main.c | 5 ----- Src/signals.c | 4 +++- Src/utils.c | 12 +++++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'Src/signals.c') diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 771ff2cf0..3cdc3b2ed 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -53,11 +53,6 @@ mod_export int zlecs, zlell; /**/ mod_export int incompctlfunc; -/* != 0 if we are in a new style completion function */ - -/**/ -mod_export int incompfunc; - /* != 0 if completion module is loaded */ /**/ diff --git a/Src/signals.c b/Src/signals.c index a848acdbe..81949843f 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -1184,7 +1184,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn) traplocallevel = locallevel; runhookdef(BEFORETRAPHOOK, NULL); if (*sigtr & ZSIG_FUNC) { - int osc = sfcontext; + int osc = sfcontext, old_incompfunc = incompfunc; HashNode hn = gettrapnode(sig, 0); args = znewlinklist(); @@ -1210,8 +1210,10 @@ dotrapargs(int sig, int *sigtr, void *sigfn) trapisfunc = isfunc = 1; sfcontext = SFC_SIGNAL; + incompfunc = 0; doshfunc((Shfunc)sigfn, args, 1); sfcontext = osc; + incompfunc= old_incompfunc; freelinklist(args, (FreeFunc) NULL); zsfree(name); } else { diff --git a/Src/utils.c b/Src/utils.c index f460c0fb3..439b43aa9 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -40,6 +40,11 @@ mod_export char *scriptname; /* is sometimes a function name */ /**/ mod_export char *scriptfilename; +/* != 0 if we are in a new style completion function */ + +/**/ +mod_export int incompfunc; + #ifdef MULTIBYTE_SUPPORT struct widechar_array { wchar_t *chars; @@ -1232,8 +1237,10 @@ callhookfunc(char *name, LinkList lnklst, int arrayp, int *retval) * to a list of jobs generated in a hook. */ int osc = sfcontext, osm = stopmsg, stat = 1, ret = 0; + int old_incompfunc = incompfunc; sfcontext = SFC_HOOK; + incompfunc = 0; if ((shfunc = getshfunc(name))) { ret = doshfunc(shfunc, lnklst, 1); @@ -1262,6 +1269,7 @@ callhookfunc(char *name, LinkList lnklst, int arrayp, int *retval) sfcontext = osc; stopmsg = osm; + incompfunc = old_incompfunc; if (retval) *retval = ret; @@ -3216,7 +3224,7 @@ getshfunc(char *nam) char ** subst_string_by_func(Shfunc func, char *arg1, char *orig) { - int osc = sfcontext, osm = stopmsg; + int osc = sfcontext, osm = stopmsg, old_incompfunc = incompfunc; LinkList l = newlinklist(); char **ret; @@ -3225,6 +3233,7 @@ subst_string_by_func(Shfunc func, char *arg1, char *orig) addlinknode(l, arg1); addlinknode(l, orig); sfcontext = SFC_SUBST; + incompfunc = 0; if (doshfunc(func, l, 1)) ret = NULL; @@ -3233,6 +3242,7 @@ subst_string_by_func(Shfunc func, char *arg1, char *orig) sfcontext = osc; stopmsg = osm; + incompfunc = old_incompfunc; return ret; } -- cgit v1.2.3 From 516ea294b8645fa910200096098575c39a55547a Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sun, 14 Aug 2011 18:34:27 +0000 Subject: 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. --- ChangeLog | 9 ++++++++- Src/exec.c | 2 ++ Src/signals.c | 17 ++++++++++++----- Src/zsh.h | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'Src/signals.c') diff --git a/ChangeLog b/ChangeLog index 95354095f..d9e63f36e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,13 @@ * unposted: Src/jobs.c: fix capitalized word in the middle of a sentence. +2011-08-14 Barton E. Schaefer + + * 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 * Src/Modules/datetime.mdd: unposted: also fix the autofeatures. @@ -15247,5 +15254,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5426 $ +* $Revision: 1.5427 $ ***************************************************** diff --git a/Src/exec.c b/Src/exec.c index 569c41cf7..a9164bc64 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2848,6 +2848,8 @@ execcmd(Estate state, int input, int output, int how, int last1) jobtab[thisjob].stat |= STAT_CURSH; if (!jobtab[thisjob].procs) jobtab[thisjob].stat |= STAT_NOPRINT; + if (is_builtin) + jobtab[thisjob].stat |= STAT_BUILTIN; } else { /* This is an exec (real or fake) for an external command. * * Note that any form of exec means that the subshell is fake * diff --git a/Src/signals.c b/Src/signals.c index 81949843f..dd39158d0 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -490,14 +490,21 @@ wait_for_processes(void) * update it. */ 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) - struct timezone dummy_tz; - gettimeofday(&pn->endtime, &dummy_tz); - pn->status = status; - pn->ti = ru; + struct timezone dummy_tz; + gettimeofday(&pn->endtime, &dummy_tz); + pn->status = status; + pn->ti = ru; #else - update_process(pn, status); + update_process(pn, status); #endif + } update_job(jn); } else if (findproc(pid, &jn, &pn, 1)) { pn->status = status; diff --git a/Src/zsh.h b/Src/zsh.h index 62ab5ade3..e3141120f 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -907,6 +907,8 @@ struct job { #define STAT_ATTACH (0x1000) /* delay reattaching shell to tty */ #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 */ struct timeinfo { -- cgit v1.2.3 From 748bd73d88ff777b6af0afd32934afb43b11ed6f Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sun, 25 Sep 2011 18:09:13 +0000 Subject: unposted: cross-reference zmodload from the modules intro doc. 29769: follow-up 29677 to handle the case where thisjob == -1. --- ChangeLog | 9 ++++++++- Doc/Zsh/modules.yo | 8 ++++++-- Src/signals.c | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'Src/signals.c') diff --git a/ChangeLog b/ChangeLog index 74f78a944..2b7f1e15c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-09-25 Barton E. Schaefer + + * 29769: Src/signals.c: handle thisjob == -1 (no foreground job) + when checking for whether a background job is allowed to suspend. + + * unposted: Doc/Zsh/modules.yo: cross-reference zmodload. + 2011-09-22 Peter Stephenson * Daniel Friesel: 29796: Completion/X/Command/_mplayer: complete @@ -15440,5 +15447,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5472 $ +* $Revision: 1.5473 $ ***************************************************** diff --git a/Doc/Zsh/modules.yo b/Doc/Zsh/modules.yo index 3f9986096..c8b846b95 100644 --- a/Doc/Zsh/modules.yo +++ b/Doc/Zsh/modules.yo @@ -6,7 +6,11 @@ Some optional parts of zsh are in modules, separate from the core of the shell. Each of these modules may be linked in to the shell at build time, or can be dynamically linked while the shell is running -if the installation supports this feature. The modules that -are bundled with the zsh distribution are: +if the installation supports this feature. +Modules are linked at runtime with the tt(zmodload) command, +see ifzman(zmanref(zshbuiltins))\ +ifnzman(noderef(Shell Builtin Commands)). + +The modules that are bundled with the zsh distribution are: includefile(Zsh/modlist.yo) diff --git a/Src/signals.c b/Src/signals.c index dd39158d0..ad688094b 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -491,7 +491,9 @@ wait_for_processes(void) */ if (findproc(pid, &jn, &pn, 0)) { if (((jn->stat & STAT_BUILTIN) || - (list_pipe && (jobtab[thisjob].stat & STAT_BUILTIN))) && + (list_pipe && + (thisjob == -1 || + (jobtab[thisjob].stat & STAT_BUILTIN)))) && WIFSTOPPED(status) && WSTOPSIG(status) == SIGTSTP) { killjb(jn, SIGCONT); zwarn("job can't be suspended"); -- cgit v1.2.3