I misled you a bit with my info. For Ctrl^C just write an int23h interrupt handler either in asm or C.
Code:
//Use (...) for C++ and (void) for C.
void interrupt (*oldbreakhandler)(...)=NULL;
void interrupt breakhandler(...)
{
//Do something
//You can just disable this by putting nothing here
//This would translate to an IRET in asm
//Turning off CTRL-C, though, is probably not what you want
//to do while building your code.
//Example:
//Uninstall any other int handlers we have installed
//Free memory
uninstallbreakhandler();
oldbreakhandler(); //Pass the int onto the orig int 23h handler
//Will terminate, but cleans up prior to terminating
}
void installbreakhandler(void)
{
disable();
//Save old handler
oldbreakhandler=getvect(0x23);
//Install our handler
setvect(0x23,breakhandler);
enable();
}
void uninstallbreakhandler(void)
{
//Restore the int vector table
disable();
setvect(0x23,oldbreakhandler);
enable();
}
DOS does not restore the int vector table if you have patched interrupts and pressed CTRL-C midway in your program. This thrashes the interrupt chain for the vectors you have patched. You would have to reboot to run your code again. The above method will allow you to press CTRL-C for debugging and will properly restore the int vector table so you can run your code again w/o having to reboot.
In a commercial build you would probably just put an IRET in the int23h handler. You will also want to patch int24h which is DOS's Critical Error Handler - not very friendly at all. Your version should help the user determine what the heck happened and why DOS failed or a DOS call failed.