Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!turnkey!orchard.la.locus.com!fafnir.la.locus.com!werth.la.locus.com!richard From: richard@locus.com (Richard M. Mathews) Newsgroups: comp.unix.wizards Subject: Re: dup2() system call Message-ID: Date: 23 Apr 91 01:44:06 GMT References: <85@morwyn.UUCP> <1991Apr20.174307.20637@NCoast.ORG> Organization: Locus Computing Corporation, Los Angeles, California Lines: 26 allbery@NCoast.ORG (Brandon S. Allbery KB8JRR/AA) writes: >(Doug Gwyn's dup2() omitted) >Reference's sake, yes --- but that was one that got some remarks about >differing errno values. (Which is why I had that remark in my comments.) Actually, the problem with Gwyn's version is the behavior when, on entry to the routine, newfd is a valid descriptor for an open file oldfd is not a valid descriptor for an open file A real dup2 (as on V7) will return EBADF and leave newfd alone. Gwyn's will return EBADF and close newfd. >For almost every use of dup2() I've ever encountered, the macro does the job. >If you absolutely NEED 100% V7 compatibility, use Doug's by all means. I had problems with the super-simple-minded version of dup2 when porting the BSD4.1 C Shell. I don't remember if it was the above problem or the problem with newfd==oldfd (I think it was the latter, and Gwyn's addresses that). Richard M. Mathews Lietuva laisva = Free Lithuania richard@locus.com Brivu Latviju = Free Latvia lcc!richard@seas.ucla.edu Eesti vabaks = Free Estonia ...!{uunet|ucla-se|turnkey}!lcc!richard