dup2
Jean-Pierre Radley
jpr at jpradley.jpr.com
Sat Feb 9 07:16:02 AEST 1991
In article <27B1CA1C.22559 at ics.uci.edu> schmidt at ics.uci.edu (Doug Schmidt) writes:
> I'm curious, is it possible to implement the dup2() system
>call using only routines available in the standard C library and other
>existing system calls?
>From the xcmalt sources:
#if !DUP2 /* For those that do not have dup2() */
#include <fcntl.h>
dup2(oldfd, newfd)
int oldfd, newfd;
{
if (fcntl(oldfd, F_GETFL, 0) == -1) /* Valid file descriptor? */
return (-1); /* No, return an error */
close(newfd); /* Ensure newfd is closed */
return (fcntl(oldfd, F_DUPFD, newfd)); /* Dup oldfd into newfd */
}
#endif /* !DUP2Thanks to Bill Allie CIS: 76703,2061 */
Jean-Pierre Radley NYC Public Unix jpr at jpradley.jpr.com CIS: 72160,1341
More information about the Comp.unix.wizards
mailing list