zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Martijn Dekker <martijn@inlv.org>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] Solaris-specific program flow corruption after subshell error exit
Date: Sun, 26 Feb 2017 23:39:51 -0800	[thread overview]
Message-ID: <170226233951.ZM7244@torch.brasslantern.com> (raw)
In-Reply-To: <c5d29308-f76f-01c9-4b1c-5c68d76be46c@inlv.org>

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)) {


  reply	other threads:[~2017-02-27  7:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-26  5:36 Martijn Dekker
2017-02-26 20:29 ` Bart Schaefer
2017-02-26 22:55   ` Martijn Dekker
2017-02-27  7:39     ` Bart Schaefer [this message]
2017-02-27 14:00       ` Martijn Dekker
2017-07-05  1:37         ` Martijn Dekker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=170226233951.ZM7244@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=martijn@inlv.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).