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, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26985 invoked from network); 19 Jul 2023 23:28:34 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Jul 2023 23:28:34 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1689809315; b=EjufADQ1VeJUxqdDOxtJ4eWk2HW1VmVM5DJtOZfSDgRAbo/YF0IMB7jZK/LnJ2xPh7HtibpjUR OeZ++Qy0IC4Oth1Wd//2Av0+r//qTOl26i2C8rLfBtOZgJxcQuLKrGAX+7BdFLs2HRXhSolDFI HOFSQYGzdgld1JYkqsCOBMgo8xVL/Pta8wA0Oyk7i6ynLfspPutmFIWfKAzak1BGD7S1Brz/pV PE38IERUVMgQ7LJs32UundwCqsiXY0ZTBZkt17gEK0Kz4eaz9enDBhB7icVU+fUmJ1BqPMnDm7 nk1E18KCqrYzi7IPECeMPRW7Pw21wqw6ju5NSCyaVJ2G/w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f52.google.com) smtp.remote-ip=209.85.218.52; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 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-20210803; t=1689809315; bh=ehc8aKOTq57NDSrn/A5QcTz3Yw4J0cZOnyCqJAocKJo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=ac7NTIv1Gb5aqiI3hdqIBiEjzWiiyZu8URplsdDQnMMquoxBPpKzgi2+FDD/WzVHzioExH4HlY S6bbZd60wGTDnZ8CDrwtIXuSvZyweYxtLhxn6y+buBAnLGJifdi94YrKaorzUXxPvk15zu4HDb GJcKnlfIZbi4vWc9jALk7ir0lAXCxLQJ+3cplagqGwE/X8YAl6zZ66BaZapiidRp60znHBDhT4 zitzttGz9puFSb7V33y1gLWNBv6QJNy08rTOkkBQOdQoBjkAZd4dlpllQnSFr2XDgDaFSsNkoQ 7Df+KJjkhyA2q+eOP8zgfFrDUANcNbVdIohXlZzE61RUag==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=YHYg2fVp7R86nKCiNMBi4TVpvQJMYlTf2z8/yjng7eE=; b=JxnTOeX4ssDvCqgxUPDDuf5i3L TD+fGW3jhSqY8XSBFohj2lUxqLz6l0PZLxklMRq+wIW1sXZ9clXkgsGAu4bSrqUGWVH3Lry1L6va3 6vuHAi5D7Kl7DZkYceMD1ytFpyQdy4jmRZsw78cjB5QmpHJsmtIO4sB4LfZkHHt+2ilgf4/V+PyRs DbmeR1aoamhsF8ksP6nyrUaiyf9IvuqgTCvbygMyO+Zz2LqgrcVILADtKuXKPYSXvlNi3JEanOPTH 0kz8sItD0kS9bXV8NhR/dsv9tlsBsIRqq5FeM1d8lkG8eqc6A22sNLDMUcjfTC5ohf3ILc9dTVlba 6B9sv1xw==; Received: by zero.zsh.org with local id 1qMGav-0005f5-WB; Wed, 19 Jul 2023 23:28:34 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f52.google.com) smtp.remote-ip=209.85.218.52; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f52.google.com ([209.85.218.52]:45409) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qMGaI-0005Kj-Jl; Wed, 19 Jul 2023 23:28:00 +0000 Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-992dcae74e0so36490766b.3 for ; Wed, 19 Jul 2023 16:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20221208.gappssmtp.com; s=20221208; t=1689809274; x=1690414074; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YHYg2fVp7R86nKCiNMBi4TVpvQJMYlTf2z8/yjng7eE=; b=RTHZgntVEu7HoJV22VstBvFaNijBdv0gsN+UzuiFiWtiERGgRx2emXdKjZc0qC9ZGO YS95NEonPX9FXVsMa+ncKSg2heKIIRbsmx+O7ACpdd79Zfj6bd2aak4oTcAW8SM+F2EB hdXAMocql4Hq1SKWi/qNvv7txrqbrhV2dwGds4q/w7BER9Y+G/8SqgPTQGgEk7Z20Iox AHT5mTMm5V8PYbV8mq6Fi3nkAcDm2jqI7/ikOBODzWhotIU2TGsnNvJV8+/ArsUKZcPV XsL6O/madcL6Lho0IeNT37m/eB9jouyFJZLHAmaUTBrqqnsXFnLE+oox3J4xSKMToTq6 c06g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689809274; x=1690414074; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YHYg2fVp7R86nKCiNMBi4TVpvQJMYlTf2z8/yjng7eE=; b=OAf8irf1wErwy57tBZgGc4Y6oYFnRxz1M4IT4PHEjl+2Yu30FHdl2bmnAnDJ28iW7n gpXE06OiI8n8oE9nksM3gARQaPJCz8ezyBJP0Krc7HyVzARhovVCcWTWdXIXR7Br4KEK HzZXJ2anpAiFLBx8bD/30swDy33aF+DEZ2EC2c2ZnNMmQkXmxOOYvTbV1ikhSdBa8Ero bLXspSP0Yg8pxs5wx0++npwIy8Qs04n0iY+3C1F5aKCVxBSet3DqvJdnF9lG0ytIYFXE RJfB8a4qeBMFukTUIqqL5t4NTSPn7v07fXR0sWU+WMC0DgrfN7+sa9w80Ip7kdrEIxIE 6Ybw== X-Gm-Message-State: ABy/qLaQUbk5fJeY+woRvbgcpbBxcV15WTC4lBYvRQibm50fMAM18OS3 o8fVkoc5Uq+i+h8SYDjyUFJmG/qIOQ7EZ8WOC0nT2Zh6KqdORfHYaAA= X-Google-Smtp-Source: APBJJlFrD906O/JEh3JLUgLIXimErcCuB9qeMWcci3elyuh8RsYJCkYj3UZ3r7RScQ9KN9VCxeiiO4hqsBwtHfYkXtI= X-Received: by 2002:a17:907:d0a:b0:993:22a2:8158 with SMTP id gn10-20020a1709070d0a00b0099322a28158mr4418619ejc.61.1689809273942; Wed, 19 Jul 2023 16:27:53 -0700 (PDT) MIME-Version: 1.0 References: <0a1c849e-433a-4b73-8687-ffe589fd8b3c@crans.org> In-Reply-To: <0a1c849e-433a-4b73-8687-ffe589fd8b3c@crans.org> From: Bart Schaefer Date: Wed, 19 Jul 2023 16:27:43 -0700 Message-ID: Subject: Re: Disowned command killed when piping NUL character To: Johan Grande Cc: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="0000000000008307f40600df6165" X-Seq: 51969 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000008307f40600df6165 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 19, 2023 at 3:29=E2=80=AFPM Johan Grande wrot= e: > I notice the following inconsistency in behavior. Is it indeed a bug? > If you change "&!" to just "&" you'll observe that the "read" is being stopped by a TTOU signal. This is happening because it's trying to reset the terminal from "cooked" to "raw" mode on the assumption that it's reading from the shell's standard input rather than the piped input. The same thing will happen with the "-s" option. This probably should be considered a bug. I believe the below is all that's necessary, but would appreciate another eyeball. diff --git a/Src/builtin.c b/Src/builtin.c index 669a47092..1568cf44c 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -6483,7 +6483,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func)) } else readfd =3D izle =3D 0; - if (OPT_ISSET(ops,'s') && SHTTY !=3D -1) { + if (OPT_ISSET(ops,'s') && SHTTY =3D=3D readfd) { struct ttyinfo ti; gettyinfo(&ti); saveti =3D ti; @@ -6531,7 +6531,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func)) delim =3D (unsigned char) ((delimstr[0] =3D=3D Meta) ? delimstr[1] ^ 32 : delimstr[0]); #endif - if (SHTTY !=3D -1) { + if (SHTTY =3D=3D readfd) { struct ttyinfo ti; gettyinfo(&ti); if (! resettty) { @@ -6691,7 +6691,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func)) /* dispose of result appropriately, etc. */ if (isem) while (val > 0 && read(SHTTY, &d, 1) =3D=3D 1 && d !=3D '\n'); - else { + else if (resettty) { settyinfo(&shttyinfo); resettty =3D 0; } --0000000000008307f40600df6165 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Jul 19, 2023 at 3:29=E2=80=AFPM J= ohan Grande <nahoj@crans.org> = wrote:
I notice the following inconsistency in behavior. Is it indee= d a bug?

If you change "&!&qu= ot; to just "&" you'll observe that the "read" = is being stopped by a TTOU signal.

This is happeni= ng because it's trying to reset the terminal from "cooked" to= "raw" mode on the assumption that it's reading from the shel= l's standard input rather than the piped input.=C2=A0 The same thing wi= ll happen with the "-s" option.

This pro= bably should be considered a bug.=C2=A0 I believe the below is all that'= ;s necessary, but would appreciate another eyeball.

diff --git a/Src/builtin.c b/Src/builtin.c
index 669a47092..1568cf44c = 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -6483,7 +6483,7 = @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
=C2= =A0 =C2=A0 =C2=A0} else
=C2=A0 readfd =3D izle =3D 0;
=C2=A0
- =C2= =A0 =C2=A0if (OPT_ISSET(ops,'s') && SHTTY !=3D -1) {
+ = =C2=A0 =C2=A0if (OPT_ISSET(ops,'s') && SHTTY =3D=3D readfd)= {
=C2=A0 struct ttyinfo ti;
=C2=A0 gettyinfo(&ti);
=C2=A0 sav= eti =3D ti;
@@ -6531,7 +6531,7 @@ bin_read(char *name, char **args, Opti= ons ops, UNUSED(int func))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0delim =3D (= unsigned char) ((delimstr[0] =3D=3D Meta) ?
=C2=A0 delimstr[1] ^ 32 : = delimstr[0]);
=C2=A0#endif
- if (SHTTY !=3D -1) {
+ if (SHTTY =3D= =3D readfd) {
=C2=A0 =C2=A0 =C2=A0struct ttyinfo ti;
=C2=A0 =C2=A0 = =C2=A0gettyinfo(&ti);
=C2=A0 =C2=A0 =C2=A0if (! resettty) {
@@ -= 6691,7 +6691,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int= func))
=C2=A0 =C2=A0 =C2=A0/* dispose of result appropriately, etc. */=
=C2=A0 =C2=A0 =C2=A0if (isem)
=C2=A0 while (val > 0 && = read(SHTTY, &d, 1) =3D=3D 1 && d !=3D '\n');
- =C2= =A0 =C2=A0else {
+ =C2=A0 =C2=A0else if (resettty) {
=C2=A0 settyin= fo(&shttyinfo);
=C2=A0 resettty =3D 0;
=C2=A0 =C2=A0 =C2=A0}

--0000000000008307f40600df6165--