Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] Solaris-specific program flow corruption after subshell error exit



On Feb 26, 11:55pm, Martijn Dekker wrote:
}
} So that appears to suggest that the problem is something to do with
} invoking exit() and not _exit() upon exiting a subshell on error. Could
} it be that the 'forked' flag contains the wrong value?

"forked" is local to that function and is correct in that the "set"
command has not forked from the (sub)shell in which it is running.

The problem seems to be that this test is not sufficient in the case
where we're exiting due to failure of a special builtin.  Instead we
also need to know whether the surrounding context is a subshell.

You might think the global "subsh" in exec.c would record that, but
it doesn't.

The following is a hack and there should probably be another way to
handle this, but try the patch below to see if it fixes the issue?
And then maybe somebody else can chime in with the right thing to be
testing here.


diff --git a/Src/exec.c b/Src/exec.c
index 83d1513..6af4ddb 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3996,6 +3996,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
 	 * classify as a builtin) we treat all errors as fatal.
 	 * The "command" builtin is not special so resets this behaviour.
 	 */
+	forked |= zsh_subshell;
     fatal:
 	if (redir_err || errflag) {
 	    if (!isset(INTERACTIVE)) {



Messages sorted by: Reverse Date, Date, Thread, Author