Mail Archives: djgpp-workers/1999/05/30/07:13:11
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 -