Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac,att!emory!wuarchive!csus.edu!ucdavis!csusac!unify!longbow!ttank!fbits!Mariusz From: Mariusz@fbits.ttank.com (Mariusz Stanczak) Newsgroups: comp.sys.3b1 Subject: Re: want workaround for "dup2" Keywords: dup2 3b1 unix-pc Message-ID: <90@fbits.ttank.com> Date: 18 Mar 91 07:52:22 GMT References: <1270@hico2.UUCP> Organization: Forth Bits Lines: 33 In article <1270@hico2.UUCP>, kak@hico2.UUCP (Kris A. Kugel) writes: > > Hummm... I don't seem to have "dup2" either. > [...] > Is there an easy way to provide dup2? The following version was included with GNU `make' dup2 (old, new) int old, new; { int newfd; (void) close (new); newfd = fcntl (old, F_DUPFD, new); if (newfd == -1) return -1; if (newfd != new) { (void) close (newfd); errno = EMFILE; return -1; } return newfd; } -Mariusz -- INET: Mariusz@fbits.ttank.com CIS : 71601.2430@compuserve.com UUCP: ..!uunet!zardoz!ttank!fbits!Mariusz