Date: Thu, 6 May 1999 12:34:58 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: djgpp-workers AT delorie DOT com cc: Charles Sandmann Subject: _clear87 at exit Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com You might remember the problem with a program that crashes due to SIGFPE on Windows: the next program you run crashes immediately at startup. I have found that adding a call to `_clear87' before exiting prevents this from happening, at least in Windows 95 and in those cases I tested. Are there any downsides to calling `_clear87' during the exit code in general and after an FP exception in particular? If not, I think we should check in this change. The modified version of `_exit' (from dpmiexcp.c) is attached below, for your reference, with the addition of the call to `_clear87' as the first thing it does. Thanks in advance for any feedback. void __attribute__((noreturn)) _exit(int status) { _clear87 (); /* We need to restore hardware interrupt handlers even if somebody calls `_exit' directly, or else we crash the machine in nested programs. We only toggle the handlers if the original keyboard handler is intact (otherwise, they might have already toggled them). */ if (__djgpp_old_kbd.offset32 == kbd_ori.offset32 && __djgpp_old_kbd.selector == kbd_ori.selector) __djgpp_exception_toggle (); __exit (status); }