Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: exit status 0 after SIGINT
On Mon, 25 Sep 2017 13:50:15 +0100
Martijn Dekker <martijn@xxxxxxxx> 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);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author