zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Johan Grande <nahoj@crans.org>
Cc: zsh-workers@zsh.org
Subject: Re: Disowned command killed when piping NUL character
Date: Wed, 19 Jul 2023 16:27:43 -0700	[thread overview]
Message-ID: <CAH+w=7YhdEMc=DFdS-uf+=WNyPw4UXC3sWfUsSNszrysUa2HPw@mail.gmail.com> (raw)
In-Reply-To: <0a1c849e-433a-4b73-8687-ffe589fd8b3c@crans.org>

[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]

On Wed, Jul 19, 2023 at 3:29 PM Johan Grande <nahoj@crans.org> wrote:

> 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 = izle = 0;

-    if (OPT_ISSET(ops,'s') && SHTTY != -1) {
+    if (OPT_ISSET(ops,'s') && SHTTY == readfd) {
  struct ttyinfo ti;
  gettyinfo(&ti);
  saveti = ti;
@@ -6531,7 +6531,7 @@ bin_read(char *name, char **args, Options ops,
UNUSED(int func))
         delim = (unsigned char) ((delimstr[0] == Meta) ?
  delimstr[1] ^ 32 : delimstr[0]);
 #endif
- if (SHTTY != -1) {
+ if (SHTTY == 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) == 1 && d != '\n');
-    else {
+    else if (resettty) {
  settyinfo(&shttyinfo);
  resettty = 0;
     }

[-- Attachment #2: Type: text/html, Size: 2273 bytes --]

      reply	other threads:[~2023-07-19 23:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 22:25 Johan Grande
2023-07-19 23:27 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7YhdEMc=DFdS-uf+=WNyPw4UXC3sWfUsSNszrysUa2HPw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=nahoj@crans.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).