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 28140 invoked from network); 13 May 2021 15:51:55 -0000
Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368)
by inbox.vuxu.org with ESMTPUTF8; 13 May 2021 15:51:55 -0000
ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1620921115;
b=QfVNXF0PO56K0ogf8qQbN2ruNw9Pj60najfo8faOqhJrE0vXIhDXwoTLvMR+S/ps26B0cgeusg
yqTDIdF+GViUZ2EUrmJ+2+g8WmqY6NMHzPQc8a+Cw55CyrNWZO3udxXL78L4JXAVCV5okI8SCn
NBFga8Q0/vDUvoN5ZougsohOUM5cJDjN7Cl+l6+a7r0EcKUEU8zfyIg9PYzdS72YXoW9cuEdOq
sVPKyyu9VvxwZIIf6VdTvCLfkk6QiM+ETrQWFc64yPwe4MUm6SUuyJfi5UOSlOY9YDvxgI0F2x
/6OzBZI9ODK3ooyV0X4OyJV5E6lIAoKhW9g/A106t/z9+A==;
ARC-Authentication-Results: i=1; zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
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=1620921115;
bh=BlSbIVpJMwxTzLYv8axraHbTGQVTGsxn1nW7DFQad2A=;
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:To:From:Date:DKIM-Signature:
DKIM-Signature;
b=UFepziPeA2kJY1KbfebsPHV1NsyYuKllwVzVwUqylkWsy6vV1nnPAVldMspxFA9Tjg9L50qwAn
rhhYpNpZy04m8wpmEwpjrLRGeOnB5bzff5VWEhV8qKPe9Vk3x6wKuriRPfJ7dYRuoUnl6hNg8j
VzbnjmYlYOFBheFmPP/eq5Bir/xAav7fW9qi4NInpcka1XujmtDHxu6APBDxxc/NMcnjQS1xTX
L80oMvHgx8/7AyM42Ftf8iCJlB0sleO2zRH1jpQKH2aP1qCfKD3LB5RG61igMwZ4XnUdlVfvcz
bT+qcaJf94nsdabh7EWR0Ur2Zh1G0YDc45K/RVKBkJvoXw==;
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:To:From:
Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=Qtwqbd1zc36Vo+ctxIgU/KOhprt/ABWPCAJE1MWXtoA=; b=bMwnOA8vshnl/RKx6hMVZfAtiD
yjTTrtGPCcmp5lAIfxSCX3pTDp3h6RQUoA+VKrxzPwYvU8tyhyjr2ftqlTfzojBQazzglf6hNq68f
F8ozf6Y4aOxIShXOtWh7pj8y/9DuSz2WrtWjp6rv2c3aF6VDjd11VDMN+O850uEeCNUPWBtgfIeeS
aXVZ7C/S6rN74nTzBMaF0QFGcSwTury/z98CSthTV/KJ2JkiLQUKrlVUdarTWyyBu3E8wm5u6mjFk
Yrj3nqz14H7Izjxx5Nl5aBKRfafuK0xllVIc1Iart6T81/jAPb5UrDg/F7GUiuN9uCK+t3ww7EPLL
oqcBfVVg==;
Received: from authenticated user by zero.zsh.org with local
id 1lhDcw-000NoS-15; Thu, 13 May 2021 15:51:54 +0000
Authentication-Results: zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:36920)
by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
id 1lhDcJ-000N68-OJ; Thu, 13 May 2021 15:51:16 +0000
Received: from [212.54.57.81] (helo=smtp2.tb.ukmail.iss.as9143.net)
by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2)
(envelope-from
)
id 1lhDcI-0003ut-NF
for zsh-users@zsh.org; Thu, 13 May 2021 17:51:14 +0200
Received: from oxbe8.tb.ukmail.iss.as9143.net ([172.25.160.139])
by smtp2.tb.ukmail.iss.as9143.net with ESMTP
id hDcIl7FAsBXJ6hDcIlanRP; Thu, 13 May 2021 17:51:14 +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=609d4af2 cx=a_exe
a=pgSR3NrKiwmx/6vnWRL19w==:117 a=jjcMUZzf2mQA:10 a=IkcTkHD0fZMA:10
a=6FF3Zhj9_vgA:10 a=aucMcf_kaHDs8VoHRyEA:9 a=QEXdDO2ut3YA:10
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=1620921074;
bh=BlSbIVpJMwxTzLYv8axraHbTGQVTGsxn1nW7DFQad2A=;
h=Date:From:To:In-Reply-To:References:Subject;
b=pUSI25vNEl0pr+ggzkeL3zB4XPuV6vSJ4GY9KgHT5ZXKpjEskSAjVRae0t3AEFbUk
A1PdJ8XQ23dUthEBM/IF31LXZ4I6KAuxgDVwl1djrxhhEP0yQXLrRhKhE2Ito9gcBa
3jcj6hPDvb//mQ7nfBVTAtjXHwcdF1II/byr4KGinv6K1hsSeYFx2WQxruhsieBpK1
vurgwaesfWEkP/FpvDNf2d1rTGUdwuTnuh3mBDggAKnDp2UzQlK92wqIYuvFOuSMcZ
iRdmfkEXDFs5ocTtPDQrHfXtk0AqGDzaUcHKhS9mHVz0s3iCY4apr1Y7Nrrpzn2MqB
zMHPF0Q4wU0ow==
Date: Thu, 13 May 2021 16:51:14 +0100 (BST)
From: Peter Stephenson
To: =?UTF-8?Q?J=C3=B6rg_Sommer?= , zsh-users@zsh.org
Message-ID: <1527863615.81691.1620921074419@mail2.virginmedia.com>
In-Reply-To: <20210513101751.j5vo2dbrd5uzwju4@jo-so.de>
References: <20210513101751.j5vo2dbrd5uzwju4@jo-so.de>
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: quoted-printable
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: MS4xfMwZI0ZYbL6pcVhLxJqaJPGVpWogpzb8EVO5bn4BHtdAutZQshe8s27tE++iY5Ptw/Dvn5VHR55WKkMlwh3HKyIWdIwP8mmjXJuNaWCXLhVCsNXKaEXE
/qGf/GsBcIc/J/AEH9TPLSAhRgVLV9j1OmZESeRKQFsaFz86HOZ1Te8aHOf9GLqAwmVMCP25CJHjjd+hIOE9o1f8f3tvsbHTFOa+23jp+07bvAUtn/BgR2YB
IXoaICLjKbi55BxBZ39O0Q==
X-Seq: 26735
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 11:17 J=C3=B6rg Sommer wrote:
> I'm using `read` in `zshexit` and when my terminal crashes (e.g. XTerm ge=
ts
> killed or ssh connection dies) Zsh spins in an endless loop until I kill =
it
> with SIGKILL (SIGTERM doesn't work).
>=20
> ```
> zshexit()
> {
> if [[ ${#${(M)${(f)"$( then
> if read -rq junk"?Root filesystem is still read-write. Remount ro=
? (y/N) "
> then
> echo
> mount -o remount,ro / || sleep 4
> else
> echo
> fi
> fi
> }
> ```
Yes, that's a clear bug. Bart's been mulling over some error handling oddi=
ties
down here, not sure if that's one of them. This is a bit of a special case=
---
how about this? Possibly other calls to zexit() might need similar treatme=
nt.
(More zsh-workers this time round, as it turns out.)
Warning: I'm currently in webmailland, too, but the diff is originally from=
a
proper Linux set up.
pws
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 0561c3b3b..e8d1260b1 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -905,7 +905,8 @@ getbyte(long do_keytmout, int *timeout, int full)
=09=09if ((zlereadflags & ZLRF_IGNOREEOF) && icnt++ < 20)
=09=09 continue;
=09=09stopmsg =3D 1;
-=09=09zexit(1, ZEXIT_NORMAL);
+=09=09if (zexit(1, ZEXIT_NORMAL))
+=09=09 return lastchar =3D EOF;
=09 }
=09 icnt =3D 0;
=09 if (errno =3D=3D EINTR) {
@@ -928,14 +929,15 @@ getbyte(long do_keytmout, int *timeout, int full)
=09 } else if (errno !=3D 0) {
=09=09zerr("error on TTY read: %e", errno);
=09=09stopmsg =3D 1;
-=09=09zexit(1, ZEXIT_NORMAL);
+=09=09if (zexit(1, ZEXIT_NORMAL))
+=09=09 return lastchar =3D EOF;
=09 }
=09}
=09if (cc =3D=3D '\r')=09=09/* undo the exchange of \n and \r determined b=
y */
=09 cc =3D '\n';=09=09/* zsetterm() */
=09else if (cc =3D=3D '\n')
=09 cc =3D '\r';
-
+=09
=09ret =3D STOUC(cc);
}
/*
diff --git a/Src/builtin.c b/Src/builtin.c
index b7ceefd55..aefd1436f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5816,10 +5816,14 @@ _realexit(void)
* ZEXIT_DEFERRED if we can't actually exit yet (e.g., functions need
* terminating) but should perform the usual interactive
* tests.
+ *
+ * If this returns 1, we are already exiting the shell: deeply
+ * embedded calls to this function should give up at that point
+ * and return an error indication.
*/
=20
/**/
-mod_export void
+mod_export int
zexit(int val, enum zexit_t from_where)
{
/*
@@ -5829,7 +5833,7 @@ zexit(int val, enum zexit_t from_where)
*/
exit_val =3D val;
if (shell_exiting =3D=3D -1)
-=09return;
+=09return 1;
=20
if (isset(MONITOR) && !stopmsg && from_where !=3D ZEXIT_SIGNAL) {
=09scanjobs(); /* check if jobs need printing */
@@ -5837,13 +5841,13 @@ zexit(int val, enum zexit_t from_where)
=09 checkjobs(); /* check if any jobs are running/stopped */
=09if (stopmsg) {
=09 stopmsg =3D 2;
-=09 return;
+=09 return 0;
=09}
}
/* Positive shell_exiting means we have been here before */
if (from_where =3D=3D ZEXIT_DEFERRED ||
=09(shell_exiting++ && from_where !=3D ZEXIT_NORMAL))
-=09return;
+=09return 0;
=20
/*
* We're now committed to exiting. Set shell_exiting to -1 to
@@ -5893,6 +5897,8 @@ zexit(int val, enum zexit_t from_where)
=09_exit(exit_val);
else
=09exit(exit_val);
+ /*NOTREACHED*/ /* I hope */
+ return 0;
}
=20
/* . (dot), source */