fails to write to coproc with "bad fd" from a compound command or subshell

Bug #1044466 reported by Ivan Zakharyaschev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gnu Bash
New
Undecided
auto-bug-bash
bash (Debian)
New
Unknown
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

When redirecting to the fd connected to a coproc, bash fails with "bad file descriptor" message.

The code is like this -- https://gitorious.org/rpush-cat/rpush-cat/blobs/continue-coproc/rpush-continue#line34 (mirror: http://repo.or.cz/w/rpush-cat.git/blob/refs/heads/continue-coproc:/rpush-continue#l34 ):

coproc ssh "$@" -e none "ls -l $DEST && cat >> $DEST"

DESTsize="$(readSizeAndroidls <&${COPROC[0]}- )" || exit $?
SRCsize="$(ls -l "$SRC" | readSizeUnixls)"
( tail -c +$((DESTsize+1)) "$SRC" | pv --wait --size $((SRCsize-DESTsize)); ) >&${COPROC[1]}-

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: bash 4.2-2ubuntu2
Uname: Linux 3.0.27-1-ac100 armv7l
ApportVersion: 2.0.1-0ubuntu12
Architecture: armhf
Date: Sat Sep 1 03:40:04 2012
SourcePackage: bash
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Ivan Zakharyaschev (imz) wrote :
Revision history for this message
Ivan Zakharyaschev (imz) wrote :

I suppose that's the same problem as explained in http://stackoverflow.com/a/12189425/94687 and http://lists.gnu.org/archive/html/bug-bash/2012-06/msg00027.html :

"Coproc file descriptors are not available to subshells. They're implemented using pipes, and leaving pipe file descriptors open in subshells causes processes to hang and not terminate properly, which results in very hard-to-track-down-and-reproduce bugs."

Although my redirection is outside of () (or {}), the file descriptor used must be available in the forked subshell, but it not might be the way bash treats fds.

Changed in bash (Debian):
status: Unknown → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.