From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27358 invoked by alias); 25 Sep 2016 17:56:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39436 Received: (qmail 26037 invoked from network); 25 Sep 2016 17:56:18 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-3.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.67):SA:0(-0.0/5.0):. Processed in 0.482158 secs); 25 Sep 2016 17:56:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.67 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=W9TFLkik c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=P5Q6L1DsAAAA:8 a=nYvI6yMcLhTLSYXzV78A:9 a=CjuIK1q_8ugA:10 a=jxi25fIUQso1YTL4nQQM:22 Date: Sun, 25 Sep 2016 18:56:11 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: [buglet] Ctrl+C and 'kill -s INT $$' should produce exit status 130 Message-ID: <20160925185611.02596fec@ntlworld.com> In-Reply-To: <13e6db91-8ba9-8709-9708-5126ce882145@inlv.org> References: <13e6db91-8ba9-8709-9708-5126ce882145@inlv.org> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 20 Sep 2016 14:17:08 +0100 Martijn Dekker wrote: > On an interactive shell, sending SIGINT to the shell (which could be > done with 'kill -s INT $$' or simply by pressing Ctrl+C) causes zsh to > return to the command prompt with an exit status of 0, which represents > a normal/successful exit. This should be 130, the exit status > corresponding to SIGINT (128+2). > > % while :; do :; done > ^C% > % echo $? # should produce 130 > 0 > % kill -s INT $$; echo oops # no output produced, as expected > % echo $? # should produce 130 > 0 It's fairly easy to do a bit better. We could add an "intlastval" to test in the main loop before we reset errflag, to use if ERRFLAG_INT is present. But I'm not sure if that's worth it; with the current fix we remain sensitive to things we shouldn't really be doing anyway on an interrupt. pws diff --git a/Src/exec.c b/Src/exec.c index a5086c3..4e89340 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3701,7 +3701,8 @@ execcmd(Estate state, int input, int output, int how, int last1) state->pc = opc; } dont_queue_signals(); - lastval = execbuiltin(args, assigns, (Builtin) hn); + if (!errflag) + lastval = execbuiltin(args, assigns, (Builtin) hn); if (do_save & BINF_COMMAND) errflag &= ~ERRFLAG_ERROR; restore_queue_signals(q); diff --git a/Src/signals.c b/Src/signals.c index 30dde71..e2587dc 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -646,6 +646,7 @@ zhandler(int sig) inerrflush(); check_cursh_sig(SIGINT); } + lastval = 128 + SIGINT; } break;