Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug: reading from tty inside process substitution



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