Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: reading from tty inside process substitution
- X-seq: zsh-workers 52304
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "Mark J. Reed" <markjreed@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: Bug: reading from tty inside process substitution
- Date: Tue, 14 Nov 2023 19:33:44 -0800
- Archived-at: <https://zsh.org/workers/52304>
- In-reply-to: <CAH+w=7ZztRXt7R9fDK=yb1=fcvjwjiUGo98j73BgBG7NzWE+iw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAA=-s3xCf4wx826U8jEjO_j5-1kcTi8v2=VZPiabKMo-meKq0Q@mail.gmail.com> <CAH+w=7ZztRXt7R9fDK=yb1=fcvjwjiUGo98j73BgBG7NzWE+iw@mail.gmail.com>
On Sun, Nov 12, 2023 at 10:09 AM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Sun, Nov 12, 2023 at 7:59 AM Mark J. Reed <markjreed@xxxxxxxxx> 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@xxxxxxxxxxxxxxxx> 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);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author