|>Is there an easy way to provide dup2? | |#include<fcntl.h> | ... if (fd_to_dup != fd) { | close(fd_to_dup); | newfd=fcntl(fd, F_DUPFD, fd_to_dup); } | ... I'm not sure this is perfect, in particular I'm not sure errno will agree with dup2(), but it's pretty close. The check to see if the fd's are equal isn't always necessary, but when it is...