www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/01/28/06:51:33

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Date: Mon, 28 Jan 2002 13:50:41 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Laszlo Molnar <laszlo DOT molnar AT eth DOT ericsson DOT se>
cc: DJGPP Workers List <djgpp-workers AT delorie DOT com>
Subject: Re: redirection problem with perl
In-Reply-To: <20020128122904.R5722@libra.eth.ericsson.se>
Message-ID: <Pine.SUN.3.91.1020128134413.26430D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 28 Jan 2002, Laszlo Molnar wrote:

> old_h = fileno(old_stream)
> old_mode = fcntl(old_h, F_GETFL)
> new_stream =  fdopen(dup(old_h), mode_to_string(old_mode))
> 
> This fails because this fcntl call always returns 0, which means fdopen
> is always called with "r" as the mode.
> 
> Any idea to work around this?

Write a DJGPP-specific functions which returns the open mode based on the 
stream's _flag member of struct FILE, and use that instead of fcntl.

Or fix the FIXME in fcntl.c that would make F_GETFL something other than 
a no-op, and then use the fixed version to build Perl ;-)

Btw, I think that the code in Perl you showed is non-portable: no one 
says that the open modes of a stdio stream and of the underlying file 
handle are identical.  For example, a stream can be open with "a" on a 
system where the filesystem doesn't know anything about append mode (i.e. 
the library implements the "a" support).  Perhaps the Perl maintainers 
should be told about that, and should prepare a macro to return this 
information, which every port will define in a system-specific fashion.

- Raw text -


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