Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwvax!zazen!uakari.primate.wisc.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!jpradley!jpr From: jpr@jpradley.jpr.com (Jean-Pierre Radley) Newsgroups: comp.unix.wizards Subject: Re: dup2 Message-ID: <1991Feb08.201602.3392@jpradley.jpr.com> Date: 8 Feb 91 20:16:02 GMT References: <27B1CA1C.22559@ics.uci.edu> Reply-To: jpr@jpradley.UUCP (Jean-Pierre Radley) Distribution: usa Organization: NYC Public Unix Lines: 20 In article <27B1CA1C.22559@ics.uci.edu> schmidt@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 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@jpradley.jpr.com CIS: 72160,1341