Date: Tue, 4 Nov 1997 13:27:57 +0200 (IST) From: Eli Zaretskii To: Nate Eldredge cc: Peter Palotas , djgpp AT delorie DOT com, DJ Delorie Subject: Re: Writing to a file from dtor doesn't work! In-Reply-To: <199711040139.RAA11038@adit.ap.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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?