delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/01/07/18:10:05

Date: Wed, 7 Jan 1998 18:09:57 -0500 (EST)
Message-Id: <199801072309.SAA27088@delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: randym AT acm DOT org
CC: djgpp-workers AT delorie DOT com
In-reply-to: <3.0.1.32.19980107133235.007d35a0@yacker.xiotech.com> (message
from Randy Maas on Wed, 07 Jan 1998 13:32:35 -0600)
Subject: Re: patch for dup2

I think if the FSEXT doesn't dup the descriptor, we should just fail.
I can't imagine that doing it ourselves would ever be the right thing
to do.

>     setmode(newfd, __file_handle_modes[fd]);
> + 
> +   /* if the fd refers to a file extension, and it didn't handle the dup2()
> +      command (eg, it is an older fsext), we can do this ourselves: just set
> +      the handle for newfd to be the same as the handler for fd, and copy the
> +      data part (this is a bug potential if the fsext is using a dynamically
> +      alloced resource for the data and it does not manage this on its own)
> +    */
> +   if (func) close(newfd);
> +   {
> +      void* data = __FSEXT_get_data(fd);
> +      __FSEXT_set_function(newfd, func);
> +      __FSEXT_set_data(newfd, data);
> +   }
> + 
>     return newfd;
>   }
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019