Waiting on a process substitution that is used in redirection for a
command grouping works, but not when using a subshell in place of that
command grouping:

    $ TIMEFORMAT=%R
    $ time bash -c '{ :; } 2> >(sleep 2); wait "$!"'
    2.013
    $ time bash -c '(:) 2> >(sleep 2); wait "$!"'
    bash: line 0: wait: `': not a pid or valid job spec
    0.008

I'd expect those two cases to behave the same way.

It looks like the redirection is done after the subshell is forked, so
adding the wait inside the subshell actually works:

    $ time bash -c '(echo "subshell \$! = $!"; wait "$!") 2> >(echo "procsub 
pid = $BASHPID"; sleep 2)'
    subshell $! = 74756
    procsub pid = 74756
    2.014

I get the same behavior with both 4.4.19 and the latest devel snapshot

-- 
Geir Hauge

Reply via email to