creps@silver.bacs.indiana.edu (Steve Creps) (01/24/88)
I have a program I'm porting from Unix to MS-DOS which makes use of
an interrupt handler to handle ^C's. Now that I have it running under
MS-DOS, this handler does not work. It seems to just ignore the ^C's.
If anyone could offer some advice I would appreciate it.
The program is setting up the interrupt handler with the call
signal(SIGINT, interrupt);
interrupt is declared as an int function of no arguments:
int interrupt();
in the file in which the call to signal occurs.
The routine looks like this:
int interrupt()
{
automatic = 0; /* clears a flag. by the way, declared extern int */
signal(SIGINT, interrupt);
}
I also looked at the code in PC NetHack, and it does pretty much the same
thing, and I noticed that unlike the Unix version of NetHack, PC NetHack
doesn't ask you if you want to quit when you type ^C; it just prints "^C" and
messes up the screen.
Any help would be appreciated.
- - - - - - - - -
Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University.
creps@silver.bacs.indiana.edu, ...iuvax!silver!creps, creps@iubacs.bitnet
"F-14 Tomcat! There IS no substitute."
asjoshi@phoenix.UUCP (01/24/88)
I don't have MSC but I know how to do what you want under TurboC. TurboC provides 3 functions for dealing with the stuff. 1)setbrk(1); /* 1=> ^C is checked 0=> don't check ^C */ 2)ctrlbrk(func); /* func is called when ^C is detected */ 3)int func() { /* cleanup */ return 0; } /* func performs cleaning up actions and DOS aborts the program if func returns 0 */ Hope this helps. I suppose that you should be able to get something equivalent in MSC :-). I know that if you don't you can write up a couple of routines that do it. I forget which but there are some DOS services which are exactly the equvalent of the above. -- Amit Joshi BITNET | Q3696@PUCC.BITNET USENET | {seismo, rutgers}\!princeton\!phoenix\!asjoshi "There's a pleasure in being mad... which none but madmen know!" - St.Dryden