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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28562 invoked from network); 13 May 2021 15:55:21 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 May 2021 15:55:21 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1620921321; b=zQfitvMmp2XgoImXypMgLzgELLSeM2j+GphyfhuIR8mI2apCUZMkVuZBUvq0xubSPm+ljwBGZq ZSAEiriQw9D1Xx4m4XVaglACR7ZeowqnH4XQ0ETZTn2iZ6rmMl5UmP2DbUAea58h6Ut9rBxsFX iCzpR4f+c5PgrGa+YuzKBJ3KweLzyKGAzNm9ASL43rlfK0SNxJlOfZUDygn8AhTDWqC7d7bWJG k7T1VPHi+rcDsb9mkhSiPj1EA0z1nAejGeM9QHlxR7Dq08v3x07pTKo4wE3zIC8t/maQOgPjzb v6SjcjcbvCZZcN1RiZtucQVaZ5BC0bam/P70UEsUUkbl6g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1620921321; bh=r+wzeJIp3UE6fL8S8HE7TFhhqS/R29o8MiGKZHJRQ/Y=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=TToxD3UY1J8P7C95Sttz9KQ0wGqdX1/vP05/l+P+oJO35sda3ubVXFynnXMfj/WszGfm2rvQXL 5ImdHow0HfVhxa312AeyjyjLnpx9iQZnLirHbjSaGQquAl2hzs9dCcGOA+eTULewkjg73CGB30 ft6UlmTpnP3gwp9Ubdac8WStytEFwvs/1ViLNjqM1iEp+D9wrDHGCTjKpkUiAnLLYPu1yDSQDL SS5lYGQCyN8tSLPbVLiabouNp+67Fg0jgImrNzoBaiXulM6wyBWNyPhe6llZWWTagUAwMKra8Y PKIef/mpwsXNp7bBMgejk9SGtwYOjyqIPnRV2PCTr4O6TA==; 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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=zyFbYhbB+sh2isMtD8rwAGqT133paonOvsSq0+NMtqg=; b=lciSQr3skhm6canie0A5u9hFl4 qwTYkuTenKqQszxAs3IHTdM7uVkGV+Y49CIbOIbrGM1urSaCAIgR7sRKr7tr7k4coaFbHQg18WXs8 1efXhb6J6tReNt59dcF44ww2+NR2hzxh6BqgOiCJKK7Psy1CA3NZWqPSMXZezm+iyI4wSqsBkR7y6 vjWYcNwzZcIKHdBXmCk0CkrHcZU8ldQlztyZP+sNlZowUJB+btTMg3kI3xe2UP1dq0gBhXxgQU6Su LZ40fP48RVIWT4ryaaPQBg+wCJK4l/VI1/RWgxbSsFM8Ga3tOXIrc2k/b3ch1xR6Bi0s/GWzV0/NX Rb87wl5A==; Received: from authenticated user by zero.zsh.org with local id 1lhDgG-000P2U-Th; Thu, 13 May 2021 15:55:20 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f174.google.com ([209.85.167.174]:41597) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lhDfG-000OI8-Qz; Thu, 13 May 2021 15:54:19 +0000 Received: by mail-oi1-f174.google.com with SMTP id c3so25682860oic.8 for ; Thu, 13 May 2021 08:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zyFbYhbB+sh2isMtD8rwAGqT133paonOvsSq0+NMtqg=; b=TFiCoVoedz0g1yDnmnZr/v9Hkckh9KP+ERXk8IhXhnoAvScxAj+yRABi9L3DFJcspd Z0fiv2NB/s67pO/uedwbL7DaGduQ2KwJNOeuofskI8H5miHJJ3xOV3/HgaQVjf39YSeW +eVGSwCvBoVrlsFuBSZWMenIpC+EwmMQAO+b/xqLhrSnRZIW/mmxJVFMne0FoehS1B6m LvMVIlwl8gNR3ri6IPN3/C91nLYcxDGJPPo4KkQPTmjwtS6Wbu4BvFAVfxPXDstDP3vd bIHXQTyrvMLYe1SUufmY0NsP1l6VW2R6NXXDY7MzEeo9MQHsWbpPr9hY6qbmGKVniPnT uzKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zyFbYhbB+sh2isMtD8rwAGqT133paonOvsSq0+NMtqg=; b=eZGHyDdeP36+72P9lH+aSamftR1newS9XSJt5ZKvZkU1bOhBqsunEl0I6OcDn7JzkI 1RBu9DOWB9Jj31f4x4h1J/wkB3Hc1npn86cagXBFCVddPho7GGdtJVE7gMucclM0+raS tbt6SLa0tKESxTu3zZNN1I8r+4rncrUC1jc52/xOtv+tSC1/gzybSGp832cHbuhHwxf8 ZWgetlOmD995kyzwx3HJR3Kbjpus7YIDrOb9AzfD5CY+vPSTokgpgJnjMlqOLMPM59RF C5bjBtoXrFim3OGnzDMj0JPbUL10D/ebYbiwHAut64z9bivyXlpJxTBl/3rnBfwqezS6 G/Xw== X-Gm-Message-State: AOAM5318MUDtFT1484TtaiRu1CvfXjfYpBs9w38Gg1M5tf5dy/Xct/S+ EBW91tSZThgwMBDr61cavmkdPbYiN4+cm2XF97yprIrc766uVQ== X-Google-Smtp-Source: ABdhPJzdhJ1mor4dlnOKKEIMNV2Jnlu7BJFjn3qtgNXBr/Je3Vb9HTJPYUJ2BVSuyBjyGL4L9HHseYqcRBkO1TKLVp4= X-Received: by 2002:aca:d90a:: with SMTP id q10mr3521703oig.173.1620921257679; Thu, 13 May 2021 08:54:17 -0700 (PDT) MIME-Version: 1.0 References: <20210513101751.j5vo2dbrd5uzwju4@jo-so.de> In-Reply-To: <20210513101751.j5vo2dbrd5uzwju4@jo-so.de> From: Bart Schaefer Date: Thu, 13 May 2021 08:54:06 -0700 Message-ID: Subject: Re: Zsh spins in endless loop with SIGHUP + read in zshexit To: =?UTF-8?B?SsO2cmcgU29tbWVy?= Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 26736 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 Thu, May 13, 2021 at 3:18 AM 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). > [...] > > So, if `raw_getbyte` returns `0` `zexit` gets called again. I think this > causes the loop. Yep. zexit() is a no-op there because it doesn't allow itself to execute recursively. There might be other places where similar loops can be triggered. I see just now PWS has also produced a different patch, which requires that zexit() return a value; I have no opinion on whether that's actually preferable. diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 0561c3b3b..9edf30e01 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -906,6 +906,8 @@ getbyte(long do_keytmout, int *timeout, int full) continue; stopmsg =3D 1; zexit(1, ZEXIT_NORMAL); + /* If called from an exit hook, zexit() returns, so: */ + break; } icnt =3D 0; if (errno =3D=3D EINTR) { @@ -929,6 +931,8 @@ getbyte(long do_keytmout, int *timeout, int full) zerr("error on TTY read: %e", errno); stopmsg =3D 1; zexit(1, ZEXIT_NORMAL); + /* If called from an exit hook, zexit() returns, so: */ + break; } } if (cc =3D=3D '\r') /* undo the exchange of \n and \r determine= d by */