From: Doug Gwyn (VLD/VMB) <gwyn at brl-vld> Your dup(2) emulation incorrectly returns an error indication if fildes2 is not open. The close(fildes2) return value should not be tested: (void)close(fildes2);