From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5343 invoked by alias); 10 Sep 2015 14:51:29 -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: 36468 Received: (qmail 1725 invoked from network); 10 Sep 2015 14:51:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f5-f794b6d000001495-b7-55f198de797b Date: Thu, 10 Sep 2015 15:51:07 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Infinite loop on exit Message-id: <20150910155107.63b8081c@pwslap01u.europe.root.pri> In-reply-to: <150910072510.ZM21990@torch.brasslantern.com> References: <20150901230743.GA12128@zira.vinc17.org> <20150902001322.GA17603@zira.vinc17.org> <150901191441.ZM15728@torch.brasslantern.com> <20150906183800.4abe1e57@ntlworld.com> <150910072510.ZM21990@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsVy+t/xq7r3ZnwMNZi4QMfiYPNDJgdGj1UH PzAFMEZx2aSk5mSWpRbp2yVwZex7d5+p4BF3xZW7u5gaGHs5uxg5OSQETCRmX9zKBmGLSVy4 tx7I5uIQEljKKLH95U12CGcGk0Tb5k5GCGcbo0TT8RZmkBYWAVWJz39usYLYbAKGElM3zWYE sUUExCXOrj3PAmILC8hJNH/rZAKxeQXsJTZcXAXWyylgJXH4+FuoDeuZJG4caQRr5hfQl7j6 9xMTxE32EjOvnGGEaBaU+DH5HthQZgEtic3bmlghbHmJzWvegg0VElCXuHF3N/sERqFZSFpm IWmZhaRlASPzKkbR1NLkguKk9FwjveLE3OLSvHS95PzcTYyQwP26g3HpMatDjAIcjEo8vAkX P4QKsSaWFVfmHmKU4GBWEuE17/sYKsSbklhZlVqUH19UmpNafIhRmoNFSZx35q73IUIC6Ykl qdmpqQWpRTBZJg5OqQbGhUlaauds9mj28zMx6vivdRdZ2ftG8oDVHK/Dqi5hTydskjj/9hOH xJl8y+LbvSfjRKexHNUI8dBv/6fUp/covWqtp+2hRM+61dMNmX6lGZX96gje/GrersyFTWWs 6ooL7p5wXtfg6LWebemVr+2P5weurFKWvXM8dqdM5LLbmhsfrlxSxsmtxFKckWioxVxUnAgA Ngu0LVgCAAA= On Thu, 10 Sep 2015 07:25:10 -0700 Bart Schaefer wrote: > Did someone fix Mikael's infinite-PS2-on-exit issue from 36407? No, it got tacked on to a thread about something else, so got missed. It was this: > zle -f > % bindkey 0 e > % e() exit > % zle -N e > % ' > quote> 0 > > this prints the PS2 prompt indefinitely, ctrl-c is ignored exit_pending is set because we need to tidy up functions before we exit. To avoid going insane, we only recover at the top level (sanitising the chain of checks to optimise this so we could exit earlier would be pretty gruesome and gain almost nothing). In that case we shouldn't try and read another character to prevent us getting there. The following works here and looks unobjectionable. Flagging an error is mostly to prevent another error message from appearing when the lexer finds out its plans have gone agley. This doesn't do anything special with ^C, but I think that was just down to Zle being rather special with interrupts, so if we don't go back into it repeatedly the issue doesn't arise. pws diff --git a/Src/hist.c b/Src/hist.c index 75e809c..9c42d85 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -390,6 +390,12 @@ ihgetc(void) { int c = ingetc(); + if (exit_pending) + { + lexstop = 1; + errflag |= ERRFLAG_ERROR; + return ' '; + } qbang = 0; if (!stophist && !(inbufflags & INP_ALIAS)) { /* If necessary, expand history characters. */