From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 9b02ba14 for ; Sat, 23 Mar 2019 18:31:28 +0000 (UTC) Received: (qmail 10380 invoked by alias); 23 Mar 2019 18:31:13 -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: List-Unsubscribe: X-Seq: 44168 Received: (qmail 25559 invoked by uid 1010); 23 Mar 2019 18:31:13 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-10.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25393. spamassassin: 3.4.2. Clear:RC:0(80.0.253.74):SA:0(-2.0/5.0):. Processed in 3.438411 secs); 23 Mar 2019 18:31:13 -0000 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.74 as permitted sender) X-Originating-IP: [86.16.88.158] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=Lv28NEVc c=1 sm=1 tr=0 a=MiHCjVqLJ44lE3bxSlffFQ==:117 a=MiHCjVqLJ44lE3bxSlffFQ==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IkcTkHD0fZMA:10 a=QY1z0GbSSfgx2LwX5o4A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1553365831; bh=OT7nWoY17DCdG0bHHU/mNIZZVl/+lF7TYltFfXShwgE=; h=Subject:From:To:Date:In-Reply-To:References; b=3p8vssxfvvoPrODDmt3g9bkZB/9J/2cDTqfrYbNmNWF5t8wGY5Vs3na3tHOBZWrnW cdM9B93Y4PZg5WFlkUE9qV4Cx5KQWskZ9qraW9VXY+gvcDkbz7aWJ+Nn/6Gme0Qo+y F3JPVBD2cgDFvj1CdjzxeSkQrAL1OiNiQBSSG7WJQHxl34rregAmFx0eD+HpCYo7t8 BQ/2g53skuCCngt4jTbOShXogDgN1y5DmpmuPGHZxfzViMqUIK+t3XefDdotbGRr5+ spBF7do8mAX/rwaisxf2bHvPV0nztlx3QQ6ed3D0mkbaVhHdK/zVGaQs2UkhSFXAVR mZyifmoTdehdw== Message-ID: <681eee2a4531f27e3b553eeb18ec4e5864858b15.camel@ntlworld.com> Subject: Re: Functions registered with zle -F stop being run after a job finishes From: Peter Stephenson To: zsh-workers@zsh.org Date: Sat, 23 Mar 2019 18:30:30 +0000 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfItiHAwnJT8bkmYXXvKIhsIU9p46yBQIUxGHAUVvEhkTUmE+za5YRKBZE6oKTkbzj75tQvLsPCbKMRzaGDVNK6dSC9Iipev8ZDr8ZKWuvfcTJn4PF0ED IqaFuoL6WkR/jixAIQK7BmzKgoeizq98LwEPvEtWnNjqdCHRxTmVWvxE > tl;dr: There appears to be a bug in zsh. When a background job finishes, > functions registered with zle -F stop running until the user presses a key > (say, [enter] or [esc]) or the shell receives a signal (any signal at all). It's going to be something like the following. Note I haven't tried this, except to confirm it compiles, but it looks like you've got a reliable way of provoking this, and this should give you enough to go on --- it's 99% certain the problem lies in that for (;;) loop surrounding the code patched here. The story is that we try to make sure errors on the -F file descriptors don't mess up the editor. The errtry flag exists to say they look suspect, so we'll try to ensure the user can continue editing even so. In your case, however, the return value from poll (probably) or select (in the unlikely event you don't have poll) is simply indicating the call was interrupted, so we can carry on trying. Not 100% sure if a "continue" or simply falling through is better here --- falling through might be better to get any remaining timeout fixed up, though that doesn't look like a problem in your case, but as the poll / select didn't give us anything useful it's otherwise better to continue. Hope this gives you enough pointers. pws diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 71930f76b..8de8e0121 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -632,7 +632,13 @@ raw_getbyte(long do_keytmout, char *cptr, int full) * with all fds, then try unsetting the special ones. */ if (selret < 0 && !errtry) { - errtry = 1; + if (errno == EINTR) { + /* Continue after interrupt */ + errflag &= ~ERRFLAG_INT; + } else { + /* Don't trust special FDs */ + errtry = 1; + } continue; } if (selret == 0) {