www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/04/06:29:01

Date: Tue, 4 Nov 1997 13:27:57 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Nate Eldredge <eldredge AT ap DOT net>
cc: Peter Palotas <blizzar AT hem1 DOT passagen DOT se>, djgpp AT delorie DOT com,
DJ Delorie <dj AT delorie DOT com>
Subject: Re: Writing to a file from dtor doesn't work!
In-Reply-To: <199711040139.RAA11038@adit.ap.net>
Message-ID: <Pine.SUN.3.91.971104132700.19533H-100000@is>
MIME-Version: 1.0

On Mon, 3 Nov 1997, Nate Eldredge wrote:

> I found the cause, but I still don't know if it's a bug. In
> src/libc/ansi/stdlib/exit.c, __stdio_cleanup_hook is called before the
> destructors. You guessed it, __stdio_cleanup_hook flushes all streams, and
> closes all except stdin, stdout, and stderr (cin, cout, cerr for C++). If
> this is not what's Supposed To Happen, it should be easy to change, just
> move two lines of code. *Are* files Supposed to work in destructors?

IMHO, people who use C++ extensively should answer this.  There might
be conflicts with objects that use I/O streams and are destructed by
global destructors.  DJ?

Is it at all safe to assume that file handles beyond the 3 standard
streams are available in the global destructor?  After all, they *are*
run after `main' returned, so at least in principle, this is a
never-never land for the application, no?

- Raw text -


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