On 10/27/2010 03:30 PM, Eric Blake wrote:
>> I just tested on OpenBSD 4.7, FreeBSD 8.1, and MirBSD 10; that reports
>> failure for all three of those distros.  However, it also reports
>> failure for dash 0.5.5.1 and latest dash.git, as well as pdksh.  So the
>> bug is pretty much inherited by all ash derivatives.
>>
>> It passes on bash, zsh, Solaris /bin/sh, and ksh93.
> 
> Actually, bash 4.1 behaves oddly:
> 
> $ bash -c 'ulimit -n 11; : <&-'; echo $?
> 0
> $ bash -c 'ulimit -n 10; : <&-'; echo $?
> bash: redirection error: cannot duplicate fd: Invalid argument
> 0

In fact, bash is *silently* losing stdin for all subsequent commands.
Compare:

$ ksh -c 'ulimit -n 8; : <&-; exec 3<&0'; echo $?
0
$ bash -c 'ulimit -n 8; : <&-; exec 3<&0'; echo $?
bash: redirection error: cannot duplicate fd: Invalid argument
bash: 0: Bad file descriptor
1

I know exactly WHY bash and other shells are trying to dup() to 10 or
greater - they MUST preserve the shell's std fds for commands after the
temporary redirection done by ': <&-'.  ksh93 is calling
fcntl(fd,F_DUPFD,3) while bash and BSD sh are using fcntl(fd,F_DUPFD,10).

At this point, I think that tar should fix its testsuite to use a larger
ulimit -n setting; 10 is just too small for most shells out there,
whether or not you also consider this a shell bug.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to