Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: reading from tty inside process substitution
- X-seq: zsh-workers 52295
- 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: Sun, 12 Nov 2023 10:09:45 -0800
- Archived-at: <https://zsh.org/workers/52295>
- In-reply-to: <CAA=-s3xCf4wx826U8jEjO_j5-1kcTi8v2=VZPiabKMo-meKq0Q@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAA=-s3xCf4wx826U8jEjO_j5-1kcTi8v2=VZPiabKMo-meKq0Q@mail.gmail.com>
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.
This has to do with the way zsh backgrounds the process substitution.
It actually works fine in a script or even in a subshell (which
explains why it works in command substitution):
% zsh -fc 'read foo < <(read bar </dev/tty; echo $bar); echo $foo'
the line
the line
% ( read foo < <(read bar </dev/tty; echo $bar); echo $foo )
subshell
subshell
%
In an interactive shell with job control, though, the process
management is different.
% unsetopt monitor
% read foo < <(read bar </dev/tty; echo $bar); echo $foo
no job control
no job control
%
I doubt there's any easy way to change this without breaking something else.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author