Problem with command substitution and pipes - dup2()

Andy Stewart andystewart at
Fri Dec 30 15:40:37 UTC 2005

Hash: SHA1

HI everybody,

I have built a cross compile environment with buildroot on my x86_64
machine which uses uClibc-0.9.28, gcc 3.4.2, and busybox 1.01 with the
2.4.30 Linux kernel (yes, I explicitly hacked in those headers to match
the kernel version I'm using).  The target machine is little endian MIPS

I have a problem where command substitution and pipes do not work in the
 shell.  I have traced the problem into the source code to where dup2()
gets called, and it returns with -EBADF (bad file descriptor).  The
printed message indicate this.  However, I don't know why this happens.
 I tried bash with the same result.

cmd sub:  echo `cat /etc/hostname`
pipe:  ls | grep foo

I checked with the ulimit command and I'm not hitting any file
descriptor limits as far as I can tell.    /proc is enabled and working
on the MIPS target.  /dev/fd is not linked to /proc/self/fd, and I added
this to no avail.  I thougth these things might be related to the
problem at hand, but perhaps not.

I can successfully use command substitution and pipes when running
busybox on my x86_64 machine, so I'm puzzled as to why they don't work
for me on the MIPS target machine.

I'm not sure how I should proceed to debug and fix this problem.  I'm
not entirely certain, but it looks like dup2() gets turned into a kernel
system call, and from there I'm lost.

Do you have any advice as to how I should proceed to debug and fix this


- --
Andy Stewart, Founder
Worcester Linux Users' Group
Worcester, MA, USA

Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -


More information about the busybox mailing list