opendir(/dev/fd/n) should fail

Eric Blake
Fri Jan 23 19:23:00 GMT 2015

On 01/23/2015 03:00 AM, Helmut Karlowski wrote:
> --------------------------------------------------
> Helmut Karlowski <> wrote:
> (23/01/2015 10:54)
>> It's not just bash. The same happens in my home-grown shell. Starting 
>> with /dev/fd/3 opendir succeeds giving (only the opendir-entries):
> Maybe it's because:
> 3 -> /proc/3008/fd/
> which recurses into /dev/fd again?

Yep. You'd get similar behavior for:

ln -s . dot

then trying to do a recursive listing of ./dot/**

Without some form of symlink recursion detection (aka "have we seen the
inode of this directory higher up in the tree?"), this will affect any
symlink-to-directory hierarchy loop.  Might be worth reporting it
upstream to see if bash is willing to add an inode hash table to prevent
infinite recursion on ** expansions across symlink loops, but as it is
not a cygwin-specific issue, I'm not going to try and do anything about
it downstream in the cygwin build of bash.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Cygwin mailing list