Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14053

Can't wait for process substitution redirected for a subshell

From Geir Hauge <geir.hauge@gmail.com>
Newsgroups gnu.bash.bug
Subject Can't wait for process substitution redirected for a subshell
Date 2018-04-24 22:46 +0200
Message-ID <mailman.12955.1524602798.27995.bug-bash@gnu.org> (permalink)

Show all headers | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Can't wait for process substitution redirected for a subshell Geir Hauge <geir.hauge@gmail.com> - 2018-04-24 22:46 +0200

csiph-web