From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16634 invoked from network); 14 May 2021 09:58:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 May 2021 09:58:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1620986281; b=KenlvNzsgYORAns7CNzH2qXQ+oLb5z0yqyqAb4MCmfzI0P+xViTmcTg9HQvGoi4DAD9tv01JYR mamhOIv6zSFfMIJtQrT2WXJCjuUYCYZuZBpGN0Qmz80JGJ+1nbNXtvzV1G8mZmHYNAGQrVoIk7 36gClhD/PWTs1Twbvt4mcVBmDnpaXmHyM5qtu08VRmcUF2HJWxrpWr92IzD4J9fgzWryvbyL7w Xmh7pRLEuCFijpxz2Sn10JNYC0jRPxkaD1AT4+LDeTHijgnoUtBueQhPPpQjs09b84R5xc+Bqp swj2K1EsfairfcavQiEPO7Nm1/Nr4FeK83LoyZpozfhBdA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1620986281; bh=HqNQ+g5aIysFeyV4Z04/EMyxHHURkf+JRvDnEtWfjZU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:Cc:To:From:Date:DKIM-Signature: DKIM-Signature; b=DILC1fckeO0lPxLbkV9VxZR0UAxKds139QvEmlfzKci9NXP54yza77OxT6fI+SHyyrdTSbGQqu n27bvblgMTYq/3uD8Hkv+eyBpTTvr0vWQLMB/AoxTYg5b6t7np4jCPR/E5mBn+bsbuRdUQ60mN 73Sf0V2pBNJNJUy/P7SZTVvaBQN5B3jyoTMhI/X04+vdxiDYX0nW7XsQB127v0eLHpZqHTTxYW e8uKfPHghV1aoz4+nPUr5mAvOIbMFKUesBh6CsJcoqRlEQeFyjeuDrMBp9pxWqoL9qbNtCGMRq +kYjsLP6N1UJ26M0aHIR/AI11LEzHgsj97jzP1yQ61nazA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=v4sgZoq0ooTSCO5Idd+xM8MsoFSuRZv8m3CXx7FOCEQ=; b=Op1RotaWJlNVh/K50HK+zgqvt5 4cA4zD3I/AUgo1jk98Si4czJh0UxSIETGXjEzsDXiJYsLRlFhtPs6FiVyo/AQxesxBZFEVEInTkCP 3Mn3FbzfX3t8TG7n3YczDU2ARXrc4+AMBIq+jPdQCWfOMQkUOkbCs7/XTXojy9+2goDMLzTEbqBoC XXPV4Y4S3DjL/TNxaeb8Z3exGrjJSlOACVBvHJGen7wU3R+Yo0/s/6jjICuuYCjMMm/4+Vrja71AD +LOXg4KhKs1vdKFcB04qlq6tGjJEb4q98oP5vAxn1VMY90j1w/qtJr8BfpFILamimkiBpeVXfwhiN 9ldmPJ+w==; Received: from authenticated user by zero.zsh.org with local id 1lhUZz-0008vk-Qo; Fri, 14 May 2021 09:57:59 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:48238) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1lhUYL-0008DH-0v; Fri, 14 May 2021 09:56:17 +0000 Received: from [212.54.57.81] (helo=smtp2.tb.ukmail.iss.as9143.net) by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1lhUYK-00035V-BY for zsh-users@zsh.org; Fri, 14 May 2021 11:56:16 +0200 Received: from oxbe8.tb.ukmail.iss.as9143.net ([172.25.160.139]) by smtp2.tb.ukmail.iss.as9143.net with ESMTP id hUYKl8L98BXJ6hUYKlbwAw; Fri, 14 May 2021 11:56:16 +0200 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-users@zsh.org X-SourceIP: 172.25.160.139 X-CNFS-Analysis: v=2.4 cv=f6cruM+M c=1 sm=1 tr=0 ts=609e4940 cx=a_exe a=pgSR3NrKiwmx/6vnWRL19w==:117 a=jjcMUZzf2mQA:10 a=IkcTkHD0fZMA:10 a=6FF3Zhj9_vgA:10 a=q2GGsy2AAAAA:8 a=NLZqzBF-AAAA:8 a=PRqe_i342nH-A3aZpJsA:9 a=QEXdDO2ut3YA:10 a=z9dJwno5l634igLiVhy-:22 a=wW_WBVUImv98JQXhvVPZ:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1620986176; bh=HqNQ+g5aIysFeyV4Z04/EMyxHHURkf+JRvDnEtWfjZU=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=ezkxV3nM7XCYJaRptCt3dCUp4i6TPKhoRwpT1lOwv4u3ggX/R/myIfWUeEjUdGJTx asLV1DfHbIxigXG4edp6eX7CTdVAXGyeFWhKUIMnUz2HcvVxjtaHSCS+88tRupiY7W 0PRNvmQlpoxmx1l5QKZEoLLDDQAx99l6614KwX5Ig9vtAmkIPLSHEEBD5+kN0wMEfr GyFSdhuapKcgCr/TgTH3X+uEHELK3WGW3X+4z1Lwfwa0UViTDqOdMp9fzbZ+IUv7QZ gJ88GayPNcZ5dnyESZvaIsAXQVjLqT/nEU83gDTb3710F4HKTjpKa9nTy5KRaUX4yl zG0/Avz+0Silg== Date: Fri, 14 May 2021 10:56:16 +0100 (BST) From: Peter Stephenson To: Bart Schaefer Cc: Zsh Users Message-ID: <979701293.98679.1620986176059@mail2.virginmedia.com> In-Reply-To: References: <20210513101751.j5vo2dbrd5uzwju4@jo-so.de> <119769213.82300.1620922030356@mail2.virginmedia.com> <0890fd16e2f7d0a8d40f621022ad541ab1c1a9ee.camel@ntlworld.com> Subject: Re: Zsh spins in endless loop with SIGHUP + read in zshexit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 147.161.167.79 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfFBVXOOFpEUtnouAgHgGSe4hw/yNpkPGnATKq8vH0gzVyU6w2bvk0fXF305S7dK9cOTdpFVWPuv7nFHsORJU8BtxEL7x8eEjmiAGYJgfzzUsSVJKFMXG NERbmyQlLfDWzHk5ykSqSe7tIVcFGatSlNNbDysxdULH7n7hha8kDIcLcd49BGciYQ9fHk7urcooDcXNuYInZoO08XmkCCBHA4fEm50tBZZT19UeOv9xYdUf TepFlMhcbAJ9iNi9jpr+UsTida2sIaDaV7Y2q2yWhD0= X-Seq: 26741 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: > On 13 May 2021 at 22:37 Bart Schaefer wrote: > On Thu, May 13, 2021 at 11:44 AM Peter Stephenson > wrote: > > > > I haven't looked for cases where we're disobeying "exit" from shell code > > owing to the same logic > > So besides the one discussed already in this thread, we have: > 1) ${unset?error message} > 2) return at top level (bin_break + BIN_RETURN) > 3) exit (bin_break + BIN_EXIT) > 3a) in a shell function (ZEXIT_DEFERRED) Focussing on this one, I tried TRAPEXIT() { while true; do exit; done; } and sure enough the shell is looping forever if I kill the terminal. (Obviously, as written that's a daft thing to do, but with an appropriate set of internal conditions it might become realistic.) This is the sort of thing I was thinking about --- the answer is probably going to be along the lines of "breaks = loops" etc. in that condition at the top of zexit(), but I haven't made a patch as I suspect there's going to be more to the can of worms. pws > 3b) at top level (ZEXIT_NORMAL) > 4) doshfunc() when not already in an exit trap > 5) loop() when (3a) has previously happened > 6) init_misc() for "zsh -c somecommand" > 7) zsh_main() at end of input (can be canceled by ignoreeof) > 8) zpty module at the end of the child thread > 9) signal handling for HUP PIPE ALRM and if not interactive INT > > (3a) uses zexit in a comma expression, I'm surprised that doesn't > produce a warning for a void function. That is the only instance of > DEFERRED. > > The only time zexit() fails to _exit() is when called recursively, > which I believe can only happen in a trap. Possible "dangerous" cases > when used in a trap: > > (1) could unexpectedly proceed beyond the parameter expansion into the > subsequent shell code. > (2,3) and by extension (4) when used in combination with an "always" > block (this is not clear-cut) would continue the shell code. > (8) would continue into the pty master code if a new zpty were opened. > > I haven't tested whether any of these things actually DO fail to > _exit(), just source code examination of what comes downstream in each > circumstance. When there is no "always", I believe 2 and 3 correctly > end processing of the current function scope. >