Xref: news2.mv.net comp.os.msdos.djgpp:1716 From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Exiting a program from a hw interrupt Date: Thu, 7 Mar 1996 16:08:17 +0000 Organization: The University of York, UK Lines: 37 Message-ID: NNTP-Posting-Host: tower.york.ac.uk Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp This is a question for Charles Sandmann, and anyone else who knows a lot about the inner workings of dpmi. I want to be able to abort my program from inside a hardware interrupt (keyboard) handler. I have a taken over a lot of interrupts, and it would be nice to have some way to kill my program when it hangs, by pressing ctrl+alt+del or some such. In djgpp 1.x just calling exit() from within the irq handler worked (I could hardly believe it, but it did :-) In djgpp 2 that is not surprisingly no longer the case. After some examination of the library sources I came up with the code fragment: asm (" movb $0x79, %al call ___djgpp_hw_exception "); which does the trick, but is hardly elegant or particularly future-proof, since it relys on the inner workings of the library (the _djgpp_hw_exception isn't even declared in any headers). So my question is, is this a safe thing to do? Is this function likely to change in later versions of the runtime library, and if so, is there any other way I can achieve the same thing? I'm also unclear as to exactly when this routine will raise the exception. As far as I can make out, my interrupt handler will finish and exit normally, and the exception will occur as soon as control returns to the main body of my code. Is this correct? If so, I can't do my program cleanup inside the irq handler (freeing an iret wrapper from inside the irq is probably a bad plan :-) so I will have to rely on an atexit() function to sort things out for me. Shawn Hargreaves If God is omnipotent, can he make a http://www.york.ac.uk/~slh100/ rock so heavy that he cannot lift it?