From 17178db1a4d8700c9e10862d0dd496f92c53f1cd Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 9 Jul 2018 11:06:07 +0100 Subject: users/23531: Error exit/return fixes. Fix regression with trap on left hand side of pipe. Fix forced return from shell structure within nested function. Fix tests exiting too early. Add new test case. --- Src/exec.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Src/exec.c') diff --git a/Src/exec.c b/Src/exec.c index d44527841..586402070 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2728,6 +2728,11 @@ execcmd_fork(Estate state, int how, int type, Wordcode varspc, if (sigtrapped[SIGINT] & ZSIG_IGNORED) holdintr(); + /* + * EXIT traps shouldn't be called even if we forked to run + * shell code as this isn't the main shell. + */ + sigtrapped[SIGEXIT] = 0; #ifdef HAVE_NICE /* Check if we should run background jobs at a lower priority. */ if ((how & Z_ASYNC) && isset(BGNICE)) @@ -5792,7 +5797,19 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) undoshfunc: --funcdepth; if (retflag) { + /* + * This function is forced to return. + */ retflag = 0; + /* + * The calling function isn't necessarily forced to return, + * but it should be made sensitive to ERR_EXIT and + * ERR_RETURN as the assumptions we made at the end of + * constructs within this function no longer apply. If + * there are cases where this is not true, they need adding + * to C03traps.ztst. + */ + this_noerrexit = 0; breaks = funcsave->breaks; } freearray(pparams); -- cgit 1.4.1