zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Mark J. Reed" <markjreed@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: Bug: reading from tty inside process substitution
Date: Tue, 14 Nov 2023 19:33:44 -0800	[thread overview]
Message-ID: <CAH+w=7ZVJeo==zJjUi7OaUWt5nRqhif2ApTk5z5a0PD9mONc4Q@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZztRXt7R9fDK=yb1=fcvjwjiUGo98j73BgBG7NzWE+iw@mail.gmail.com>

On Sun, Nov 12, 2023 at 10:09 AM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> On Sun, Nov 12, 2023 at 7:59 AM Mark J. Reed <markjreed@gmail.com> wrote:
> >
> > The below code hangs after reading the line from the terminal:
> >
> >     read foo < <(read bar </dev/tty; echo $bar)
>
> I believe it actually hangs before reading the line from the terminal,
> or more precisely at the point of trying to read the line.  "read bar"
> is being stopped by a SIGTTIN signal because it is not in a process
> group that "owns" the TTY.
>
> I doubt there's any easy way to change this without breaking something else.

I seem to have proven myself wrong.  Can anyone think of a use-case
for doing job control inside a <<(subshell) ?

On Sun, Nov 12, 2023 at 1:50 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> This is even worse:
>
> read foo < <(read bar; echo $bar) </dev/tty

That still doesn't respond to interrupts, but with the below change
will stop on ctlr-d (EOF) on the tty.


diff --git a/Src/exec.c b/Src/exec.c
index 285d2c5ad..f4a71fd03 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5096,7 +5096,7 @@ getpipe(char *cmd, int nullexec)
        procsubstpid = pid;
        return pipes[!out];
     }
-    entersubsh(ESUB_ASYNC|ESUB_PGRP, NULL);
+    entersubsh(ESUB_ASYNC|ESUB_PGRP|ESUB_NOMONITOR, NULL);
     redup(pipes[out], out);
     closem(FDT_UNUSED, 0);     /* this closes pipes[!out] as well */
     cmdpush(CS_CMDSUBST);


  parent reply	other threads:[~2023-11-15  3:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 15:59 Mark J. Reed
2023-11-12 18:09 ` Bart Schaefer
2023-11-12 21:50   ` Bart Schaefer
2023-11-15  3:33   ` Bart Schaefer [this message]
2023-11-15  4:42     ` Bart Schaefer
2023-11-15  5:00       ` Bart Schaefer
2023-11-16  4:58         ` Bart Schaefer
2023-11-17  1:27           ` [PATCH] reading from large or "infinite" source in multio Bart Schaefer
2023-11-18 23:24             ` Bart Schaefer
2023-11-16  2:35       ` [PATCH] reading from tty inside process substitution Bart Schaefer

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=7ZVJeo==zJjUi7OaUWt5nRqhif2ApTk5z5a0PD9mONc4Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=markjreed@gmail.com \
    --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).