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

Path csiph.com!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!171.64.64.130.MISMATCH!usenet.stanford.edu!not-for-mail
From Geir Hauge <geir.hauge@gmail.com>
Newsgroups gnu.bash.bug
Subject Can't wait for process substitution redirected for a subshell
Date Tue, 24 Apr 2018 22:46:26 +0200
Lines 26
Approved bug-bash@gnu.org
Message-ID <mailman.12955.1524602798.27995.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1524602798 23720 208.118.235.17 (24 Apr 2018 20:46:38 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=wwu9SNF37ms8d/XGIN1mTHTIIoRETtXJaXtaOPaG3Tw=; b=McXI83YDxyGDddpx9fBtSjbcs2Bu2zMLzCMmEErd4H4cWkkSxhUVy1x9mdwG/59inr OvrX9ADKcH0k07NblaRYacl7lJoKNj6D+E0MEvidqJjQ+h0Do0WMScRSiMc+BJ1i0oiv EjFWfvsek979lK6IZ6CswU59fsGZL6ZX62ykxvL30bIX6pPHMtakAvhwdY3u46NMiIMf sN+D2hwioRKZ/oH2oWgLX0zwCK93jby0qXGg+k1dqRnV9/yil8sQQVe7zLuiIfiv4jjE JUS9zOuCU9k952fSLGC9T3ey7bwKvld2925wOxS8ewTXon32nS14WL0Ve71Uz7wdZCFv YpeA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=wwu9SNF37ms8d/XGIN1mTHTIIoRETtXJaXtaOPaG3Tw=; b=CvZHygXbwdOiRXC90GPqvClZOqXms3zWuBgHqP7anyC4WPcVXH5Q66Zy0O0NAzPbob Taw4izXgFRHiKh6jWhM3RriNVNtVgYLFg91+J2oH33SzA3ySBLh2fBzZeh7aodwBoht0 0J2xCyR1Fb1IL6DK88kX/wc8ph6z6EJFLvINqewASfbamzUOJ131rNgyVXnDSlJNkCFF A+45cbCjK9PCrwJaX8qXdDdnp9l3erRCIwPAp6M5343w5FjklHe9uhte535pSwzroI7Q c50sf7fCzM7bWiF4TZI9nQhtUueCnnNaR28WM+qBKh0RJXLecDETK52Fs/YEALsH9tZr s2lg==
X-Gm-Message-State ALQs6tA+c9xxrEHJXM2QJB2LTxwsLvdUhaVm46XLpbce4ksIAIW4xcoe cubG4yv6ERvfUwpxCxyhWePk+YVG
X-Google-Smtp-Source AB8JxZpegEMTTjeK99SnkR4HhJyikanfi4QZyytJprUYwui0a6H9zjPVhMWUjo10vEzzXu/fYZs5Xg==
X-Received by 2002:a19:17e9:: with SMTP id 102-v6mr12886071lfx.131.1524602788386; Tue, 24 Apr 2018 13:46:28 -0700 (PDT)
Content-Disposition inline
User-Agent NeoMutt/20180323
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2a00:1450:4010:c07::22d
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14053

Show key headers only | 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