From: corinna DOT vinschen AT cityweb DOT de (Corinna Vinschen) Subject: Re: Error in dup??? 14 Nov 1998 07:17:02 -0800 Message-ID: <364D9ED0.6C6A9FEC.cygnus.cygwin32.developers@cityweb.de> References: <19981114041054 DOT 582 DOT rocketmail AT send1b DOT yahoomail DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: earnie_boyd AT yahoo DOT com, cygwin32-developers AT cygnus DOT com Earnie Boyd wrote: > > ---Corinna Vinschen wrote: > > > ... > > close(0); > > (void) dup(foo_fd); > > ... > > > > It appears that the coder is assuming that dup will use the first > available file descriptor. This may not be true in all cases. > [...] X/Open Portability Guide, XSI System Interfaces (Quotation): [...] fid = dup(fildes); is equivalent to fid = fcntl(fildes, F_DUPFD, 0); [...] F_DUPFD Return a new file descriptor which is the lowest numbered available (i.e., not already open) file descriptor greater than or equal to the third argument [...] Corinna