This looks like we never get to the bottom to actually call fcntl() which I take to mean that we do not have a test for a working call to dup2(). sparc But we need to be careful because fcntl(F_DUPFD) which is called has slightly different semantics. I suspect that fcntl(F_DUPFD) is wrong. See fcntl.c:55 for more details.