[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: some problems with scope of fds in process substitution
From: |
Stephane Chazelas |
Subject: |
Re: some problems with scope of fds in process substitution |
Date: |
Sun, 3 Dec 2017 23:07:22 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
2017-12-03 17:31:00 -0500, Chet Ramey:
> On 12/1/17 2:00 PM, Stephane Chazelas wrote:
>
> > Also, there's a lot of problems reported at
> > unix.stackexchange.com at least that are caused by bash not
> > waiting for the processes started by process substitutions,
> > especially the >(...) form.
>
> Bash always reaps these processes. Do you mean waiting for them
> to terminate before executing the next command?
[...]
Hi Chet,
yes, that's what I meant as in:
$ rm -f a; bash -c 'echo test > >(cat > a); cat a'
$
In:
cmd1 <(cmd2)
cmd3
It's usually OK not to wait for cmd2, same as
cmd2 | cmd1
cmd3
where not all shells wait for cmd2 (before running cmd3).
as cmd1 will generally wait for cmd2 by virtue of it waiting on
eof on the pipe but in:
cmd1 >(cmd2)
It's more cmd2 that would be waiting for cmd1. So when cmd1
returns, often, cmd2 has not finished yet, and if cmd3 needs
something produced by cmd2, that's where we run into problems.
See the link I gave (https://unix.stackexchange.com/a/403788)
for more details including the situation with other shells that
implement process substitution (ksh, zsh, rc, es).
Cheers
Stephane