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 2470 invoked from network); 14 May 2021 17:46:40 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 May 2021 17:46:40 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1621014400; b=i6U6Vke4zR/t1obiX0kf/mbtAh7dBVOeUHvgvMWMVBZIFOCPBt/VatVmqy0YMUXw1JbX93r7kS dBWKrKVPCNWOSC+r+rUpmuxg/OfY8stEg2WG5s/o2M6Pn0rN8kYBRMzXtx+0PoWZnXZQuxspHp IC9FYkaFYAbAHRxT9/BUtYBccVkCcVsNAWXe5Sc9zn6oRzRl6IFhOUPNUEQ6FXNNHaxHwwSKUw JosVj6ohTyAHCqOdC7wPxxgo9f9HECFZlBgErOSpXRp8rxnWzDzFvdizeqqO3pN1jpNqY8Z4J+ 5INsTeR2+Kbsqj0c5ib9DEokBPnb/ONg4ON9ahbc5oyZKw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (know-smtprelay-omc-1.server.virginmedia.net) smtp.remote-ip=80.0.253.65; 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=1621014400; bh=pNtQS9gMYYUdyx01DYR+/TE6qNpIbyiMABuNuQxLNlQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Content-Type: References:In-Reply-To:Date:To:From:Subject:Message-ID:DKIM-Signature: DKIM-Signature; b=gGhW4JrbdSKevLKh7hVxkzUMigv6AMwzIuksI+u6d/zqC2q2/YzCqgZI1fw+UYzwE+JYCcbL57 sIuOCHj3wQcNi6WT6psUyWJ4cYACWvE5pO98ySs0nLCbYXeScI0T5QpTQ3YmLPJsiXDM2ZDiP2 9faYO8/u5lFBf6KJ9dFlhq0/w1ifH6GeC6Ww/GDRFrG19bTyljSx+RMsbN6pnaapgg5rN59Nmi WMgjyyxE4F/rBKiYFoy+4T2GrJb0OPUju1oz3rp8eoy3Deu9+fR6uxkPwr0Ba+ML4vDyrH2n5Z 4TNXUdNPfiuIVqSyYTl3T8I9txeTKoHNucCoVcBOcOuJPQ==; 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: Mime-Version:Content-Type:References:In-Reply-To:Date:To:From:Subject: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=PY1uqNv8+N1M0I37lb3JpS9OdFnLdrDfmtLmpOP9buo=; b=HXYtGWU3LO00cbnHZpIYEc4KkJ 4JbH9rq2nld4rCWOPoVaRoJIX0tzIRu+ZyEZMBdFAvEBiGLhDLElNpHfwmDX4UdjltoriB4cHp8Zu ezRBYL5RwevD2xcsHrY2NxXaGcoEiBD7iY5cIwRxTi5Sqlk8494A+ZDAlKeNWY+AK5axXdQEGdeUM pxS1qDWiXOvCs4nYBpkjwegW9xzlAZimXP75g2LenHwWpNRcMU3/HHYf2QZOEEPgQ+7XfkGPrZpFx w1Llc/DD1hZj6oQW83Z/esC4kaKXNXaOHhdgMlAMHLHUTkxanbDVxmanz3EpzUfVyRizoOgHhfGFO W6arvesQ==; Received: from authenticated user by zero.zsh.org with local id 1lhbtW-000LKJ-PW; Fri, 14 May 2021 17:46:38 +0000 Authentication-Results: zsh.org; iprev=pass (know-smtprelay-omc-1.server.virginmedia.net) smtp.remote-ip=80.0.253.65; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from know-smtprelay-omc-1.server.virginmedia.net ([80.0.253.65]:45696) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lhbrl-000KZm-Ge; Fri, 14 May 2021 17:44:50 +0000 Received: from pws-Zeus ([82.20.19.64]) by cmsmtp with ESMTPA id hbrklKT5CmjUKhbrklHVOC; Fri, 14 May 2021 18:44:48 +0100 X-Originating-IP: [82.20.19.64] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=MadCRa3f c=1 sm=1 tr=0 cx=a_exe a=FYxK54AnRTbDA0SLc6W5Eg==:117 a=FYxK54AnRTbDA0SLc6W5Eg==:17 a=IkcTkHD0fZMA:10 a=v3-DDQTwOqX5hWUgSUIA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1621014288; bh=PY1uqNv8+N1M0I37lb3JpS9OdFnLdrDfmtLmpOP9buo=; h=Subject:From:To:Date:In-Reply-To:References; b=nDGoerV7DZvn5ddS2D0pJo9HKHm9fKZtCH4z3aneKMQG1iGOyMA0ZMsX17sp4kfUT LIY+umBQ/QcChIzwaNU8F+V6KhlJX5nQOULfnquQAaT+rtbI8wJSTwdqO1iOos0WxA tCbLN5ou2oOX7ZxaR/tEKyc6+Zys7QO7BOZH89pxK7Nw2LMA3gVDxpgbblxjlH6aCt RobiNUFXWfpjHmv9qHIJd/2Piwmx41G4S1o9pRwOrKAY4DlIvXw3r4+/pOZwnLs/YG aM1vwyhQXVRcvrCnl47NmNBsV9Z02tfgyrwTqZjmESFb8e8kkvSZb0brMw+wlRSCWU UQBg4HwlRdECw== Message-ID: Subject: Re: Zsh spins in endless loop with SIGHUP + read in zshexit From: Peter Stephenson To: zsh-users@zsh.org Date: Fri, 14 May 2021 18:44:48 +0100 In-Reply-To: <979701293.98679.1620986176059@mail2.virginmedia.com> References: <20210513101751.j5vo2dbrd5uzwju4@jo-so.de> <119769213.82300.1620922030356@mail2.virginmedia.com> <0890fd16e2f7d0a8d40f621022ad541ab1c1a9ee.camel@ntlworld.com> <979701293.98679.1620986176059@mail2.virginmedia.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfLCcB4dMFJhHp3YBMDTrJvGD7iTKKw/NJH/HdnzOAdN92i143awoUKHNRBR6KTRZ3CHPDmGEF/nb/Qx03xUvVX6UQVr3kNxH/NRRy4fQ4+9oQLW1+kFV 7upNrucKv+bkRQNyb/Bdk0ON9AmEtfJ4LJQjnImEDh139PAKJL47Q9AQ X-Seq: 26742 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 Fri, 2021-05-14 at 10:56 +0100, Peter Stephenson wrote: > > 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. Actually, this seems to work and may be one of the less complicated aspects of this. pws diff --git a/Src/builtin.c b/Src/builtin.c index b7ceefd55..a29eb49e4 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5828,8 +5828,11 @@ zexit(int val, enum zexit_t from_where) * a later value always overrides an earlier. */ exit_val = val; - if (shell_exiting == -1) + if (shell_exiting == -1) { + retflag = 1; + breaks = loops; return; + } if (isset(MONITOR) && !stopmsg && from_where != ZEXIT_SIGNAL) { scanjobs(); /* check if jobs need printing */