Date: Sun, 30 May 1999 14:10:54 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: djgpp-workers AT delorie DOT com Subject: Exit code closes handles 3 and 4 Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com The stdio hook that gets run as part of the exit code before the application terminates walks all the FILE objects and fflushes and closes all the associated files. The only exceptions are FILE objects whose handles are 0, 1, or 2. This is all okay (closing standard input/output/error is generally a bad idea), but what about handles 3 and 4? These are also pre-connected (to PRN and AUX devices), so it would seem we shouldn't close them, either. This rarely matters, except if you let a program exit normally under a debugger. Since the debugger and the debuggee share the initial file handles and use the same JFT in the debugger's PSP, the moment the debuggee closes handles 3 and 4, the debugger loses this handles as well! I think that we shouldn't close handles 3 and 4 before exiting. Comments?