bug-bash
[Top][All Lists]
Advanced

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

Can't wait for process substitution redirected for a subshell


From: Geir Hauge
Subject: Can't wait for process substitution redirected for a subshell
Date: Tue, 24 Apr 2018 22:46:26 +0200
User-agent: NeoMutt/20180323

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

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