zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: exit status 0 after SIGINT
Date: Mon, 25 Sep 2017 14:57:17 +0100	[thread overview]
Message-ID: <20170925145717.13849173@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <2f98bd49-1439-2bd9-c7b2-7d05ac8678fc@inlv.org>

On Mon, 25 Sep 2017 13:50:15 +0100
Martijn Dekker <martijn@inlv.org> wrote:
> zsh in interactive mode sets the exit status to 0 after sending itself
> SIGINT using the 'kill' command. I'd expect 130 (= 2 + 128).

We ignore interrupts that happened in bulltins, in this case the "kill"
that just got interrupted.  This looks pretty clearly wrong.

One minimal fix is to keep the current lastval if there's an interrupt
flagged.  Alternatively, we could keep the builtin status if it was
non-zero.

I doubt we're going to track down side effects without trying it out.

pws


diff --git a/Src/exec.c b/Src/exec.c
index bd242d1..161d4ac 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3999,8 +3999,15 @@ execcmd_exec(Estate state, Execcmd_params eparams,
 		    state->pc = opc;
 		}
 		dont_queue_signals();
-		if (!errflag)
-		    lastval = execbuiltin(args, assigns, (Builtin) hn);
+		if (!errflag) {
+		    int ret = execbuiltin(args, assigns, (Builtin) hn);
+		    /*
+		     * In case of interruption assume builtin status
+		     * is less useful than what interrupt set.
+		     */
+		    if (!(errflag & ERRFLAG_INT))
+			lastval = ret;
+		}
 		if (do_save & BINF_COMMAND)
 		    errflag &= ~ERRFLAG_ERROR;
 		restore_queue_signals(q);


  reply	other threads:[~2017-09-25 14:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170925125104epcas5p3948e0702e32903ad3a09070937edbb54@epcas5p3.samsung.com>
2017-09-25 12:50 ` Martijn Dekker
2017-09-25 13:57   ` Peter Stephenson [this message]
2017-09-26 10:57     ` Martijn Dekker
2017-09-26 17:49       ` Bart Schaefer
2017-09-27  8:35         ` Peter Stephenson
2017-09-27 19:59           ` Bart Schaefer
2017-09-26 18:15       ` Peter Stephenson

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=20170925145717.13849173@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --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).