What is the dup2() command ? - (nf)

donn at hp-dcd.UUCP donn at hp-dcd.UUCP
Wed Nov 23 18:32:49 AEST 1983


#R:bpa:-19200:hp-dcd:3200004:000:408
hp-dcd!donn    Nov 16 09:42:00 1983

On dup2().

A emulation using fcntl and F_DUPFD was suggested, but it doesn't always
work.  If you read dup2() documentation carefully it does a dup to
*exactly* its argument, doing a close if necessary.  Fcntl does it to
the first available slot >= its argument.  Thus the suggested emulation
doesn't always work.  The emulation is:

	close(arg);
	fcntl(fd, F_DUPFD, arg);

Donn Terry
...hplabs!hp-dcd!donn



More information about the Comp.unix.wizards mailing list