John,
Please don't mess with these exception handlers unless you REALLY know what is behind them in your OS!
They are to handle system events (interrupts) , Sigint is the only one you need be concerned about!
#ifdef TARGET_DJGPP
sigintkey = __djgpp_set_sigint_key(ESCKEY);
#endif
#ifdef TARGET_MINGW
/* Launch a thread to poll the escape key to emulate asynchronous SIGINTs */
if (sigintthread == 0)
sigintthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&watch_escape, NULL, 0, NULL);
#endif
The code for the TARGET_DJGPP sets up an interrupt under DOS and links it with the Escape Key, this then diverts the interrupt to the exception handler routine! this means that the escape key is handled asynchronously to the basic interpreter, which was done to allow Escape to work even when in the middle of a System() call to the OS, used for *commands
Under a Linux console I believe the default key combination of Sigint is Ctrl C, hence the program breakout with this key combination !
The TARGET_MINGW code sets up a thread to monitor the Escape key using the polling function watch_escape(), this code should be applicable under linux but you may (or may not) have to rewrite the watch_escape() function !
#ifdef TARGET_DJGPP
(void) __djgpp_set_sigint_key(sigintkey);
#endif
#ifdef TARGET_MINGW
if (sigintthread != NULL) TerminateThread(sigintthread, 0);
#endif
This code removes the handlers before BASIC exits
The use of an asynchronous escape event causes a whole raft of possible problems which are not deterministic in nature, making debugging a nightmare, hence my decision to look for the Escape key in the keyboard polling loop, I then always know the calling point for the escape event and the behavior is deterministic. The down side is that you then need to implement emulation code for all the shell commands you would have called by the System() function but this command opens a console window (which is undesirable) anyway.
PS The "shell" type *commands in BB4W are all emulated too !