* exit status 0 after SIGINT @ 2017-09-25 12:50 ` Martijn Dekker 2017-09-25 13:57 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Martijn Dekker @ 2017-09-25 12:50 UTC (permalink / raw) To: Zsh hackers list zsh in interactive mode sets the exit status to 0 after sending itself SIGINT using the 'kill' command. I'd expect 130 (= 2 + 128). Interestingly enough, pressing Ctrl+C does set the exit status to 130. % [presses Ctrl+C] % echo $? 130 % kill -s INT $$ $ echo $? 0 - Martijn ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exit status 0 after SIGINT 2017-09-25 12:50 ` exit status 0 after SIGINT Martijn Dekker @ 2017-09-25 13:57 ` Peter Stephenson 2017-09-26 10:57 ` Martijn Dekker 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2017-09-25 13:57 UTC (permalink / raw) To: Zsh hackers list 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); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exit status 0 after SIGINT 2017-09-25 13:57 ` Peter Stephenson @ 2017-09-26 10:57 ` Martijn Dekker 2017-09-26 17:49 ` Bart Schaefer 2017-09-26 18:15 ` Peter Stephenson 0 siblings, 2 replies; 7+ messages in thread From: Martijn Dekker @ 2017-09-26 10:57 UTC (permalink / raw) To: Zsh hackers list Op 25-09-17 om 14:57 schreef Peter Stephenson: > 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. An oddity remains: % kill -s INT $$ || echo oops % echo $? 1 % kill -s INT $$ && echo oops % echo $? 130 Both should be 130. This is the same when using external 'kill' (e.g. after 'disable kill'). Thanks, - M. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exit status 0 after SIGINT 2017-09-26 10:57 ` Martijn Dekker @ 2017-09-26 17:49 ` Bart Schaefer 2017-09-27 8:35 ` Peter Stephenson 2017-09-26 18:15 ` Peter Stephenson 1 sibling, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2017-09-26 17:49 UTC (permalink / raw) To: Zsh hackers list On Sep 26, 11:57am, Martijn Dekker wrote: } } % kill -s INT $$ || echo oops } % echo $? } 1 I can't "git pull" because sf.net is down right now, but: diff --git a/Src/exec.c b/Src/exec.c index bd242d1..0d2dc4e 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3199,7 +3199,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, } if (errflag) { - lastval = 1; + if (!lastval) + lastval = 1; if (oautocont >= 0) opts[AUTOCONTINUE] = oautocont; return; ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exit status 0 after SIGINT 2017-09-26 17:49 ` Bart Schaefer @ 2017-09-27 8:35 ` Peter Stephenson 2017-09-27 19:59 ` Bart Schaefer 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2017-09-27 8:35 UTC (permalink / raw) To: Zsh hackers list On Tue, 26 Sep 2017 10:49:47 -0700 Bart Schaefer <schaefer@brasslantern.com> wrote: > diff --git a/Src/exec.c b/Src/exec.c > index bd242d1..0d2dc4e 100644 > --- a/Src/exec.c > +++ b/Src/exec.c > @@ -3199,7 +3199,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, > } > > if (errflag) { > - lastval = 1; > + if (!lastval) > + lastval = 1; > if (oautocont >= 0) > opts[AUTOCONTINUE] = oautocont; > return; I'll forget mine since this appeared first. pws ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exit status 0 after SIGINT 2017-09-27 8:35 ` Peter Stephenson @ 2017-09-27 19:59 ` Bart Schaefer 0 siblings, 0 replies; 7+ messages in thread From: Bart Schaefer @ 2017-09-27 19:59 UTC (permalink / raw) To: Zsh hackers list On Sep 27, 9:35am, Peter Stephenson wrote: } } I'll forget mine since this appeared first. Sourceforge is still down. Or rather they're down *again* after having briefly been back up. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exit status 0 after SIGINT 2017-09-26 10:57 ` Martijn Dekker 2017-09-26 17:49 ` Bart Schaefer @ 2017-09-26 18:15 ` Peter Stephenson 1 sibling, 0 replies; 7+ messages in thread From: Peter Stephenson @ 2017-09-26 18:15 UTC (permalink / raw) To: Zsh hackers list On Tue, 26 Sep 2017 11:57:33 +0100 Martijn Dekker <martijn@inlv.org> wrote: > % kill -s INT $$ || echo oops > % echo $? > 1 > % kill -s INT $$ && echo oops > % echo $? > 130 > > Both should be 130. It's probably something like this. Hard to know under exactly what circumstance to change the value but leaving it alone if it's already non-zero doesn't seem too idiotic. Soureforge is down at the moment. pws diff --git a/Src/exec.c b/Src/exec.c index bd242d1..75a9f2b 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3199,7 +3199,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, } if (errflag) { - lastval = 1; + if (!lastval) + lastval = 1; if (oautocont >= 0) opts[AUTOCONTINUE] = oautocont; return; ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-09-27 19:59 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20170925125104epcas5p3948e0702e32903ad3a09070937edbb54@epcas5p3.samsung.com> 2017-09-25 12:50 ` exit status 0 after SIGINT Martijn Dekker 2017-09-25 13:57 ` Peter Stephenson 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
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).