bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: waiting for process substitutions


From: Zachary Santer
Subject: Re: waiting for process substitutions
Date: Tue, 2 Jul 2024 22:34:32 -0400

On Tue, Jul 2, 2024 at 9:59 PM Zachary Santer <zsanter@gmail.com> wrote:
>
> I *am* seeing a difference between having lastpipe enabled (and job
> control off) or not when running your example in the interactive
> shell, though:
> SECONDS=0; echo $'foo\nbar' | tee >(echo first ; exit 1) >(wc ; sleep
> 10 ; echo wc) >(tail -n 1; echo tail); wait; printf '%s\n'
> "SECONDS=${SECONDS}"
>
> With lastpipe disabled, wait exits immediately. With lastpipe enabled,
> it does seem to wait for everything.

Though this would be because, without lastpipe enabled, the child
processes for the process substitutions are being forked in what is
already a subshell environment, so no record of them would exist in
the parent shell where wait is being called. Nevermind.

Compare this:
SECONDS=0; echo $'foo\nbar' | { tee >(echo first ; exit 1) >(wc ;
sleep 10 ; echo wc) >(tail -n 1; echo tail); wait; printf '%s\n'
"SECONDS=${SECONDS}"; }

In this example, the call to wait occurs in the same shell environment
that the process substitutions were forked in, whether lastpipe is
enabled or not. Now the behavior is the same either way.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]