delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/30/07:13:11

Date: Sun, 30 May 1999 14:10:54 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: Exit code closes handles 3 and 4
Message-ID: <Pine.SUN.3.91.990530140328.20904E-100000@is>
MIME-Version: 1.0
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?

- Raw text -


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