want workaround for "dup2"

John R. MacMillan john at chance.UUCP
Tue Mar 19 15:37:08 AEST 1991


|>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...



More information about the Comp.sys.3b1 mailing list