On 11/6/12 7:09 AM, Zev Weiss wrote: > Bash Version: 4.2 > Patch Level: 39 > Release Status: release > > Description: > > It seems that when bash passes (the expanded form of) a > process substitution to a function and that function then uses > the argument in a pipeline, the file descriptor for the > substituted pipe gets closed prematurely. This does not occur > with bash-4.1.11 on FreeBSD, but does with 4.2.39 on Linux (I > attempted to compile 4.1.11 from source on Linux to test it, > but the build failed). > > Repeat-By: > Shell transcript demonstrating it: > > [zev@hatter: tmp]% cat test.sh > #!/bin/bash > fn() { cat | cat "$1"; } > fn <(:) < /dev/null > [zev@hatter: tmp]% bash ./test.sh > cat: /dev/fd/63: No such file or directory > [zev@hatter: tmp]% echo $? > 1 > > Expected behavior is no output and an exit status of zero.
Thanks for the report. The difference you observed is not the change from bash-4.1 to bash-4.2, but Linux using /dev/fd and FreeBSD using explicitly-created and destroyed FIFOs. It's important to close /dev/fd file descriptors (which are essentially pipes) in the various processes that use and inherit them. The bash-4.2 (and previous) code closes those file descriptors after creating the first process in a pipeline instead of, say, the last (thereby making them unavailable to the rest of the pipeline processes). I will look at changing that for the next version. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/