1 #include <fcntl.h> 2 3 int dup2(int fd1,int fd2)4 dup2 (int fd1, int fd2) { 5 close (fd2); /* ignore errors, if any */ 6 return (fcntl (fd1, F_DUPFD, fd2)); 7 } 8