Xref: news2.mv.net comp.os.msdos.djgpp:3551 From: stwand07 AT uctvms DOT uct DOT ac DOT za Newsgroups: comp.os.msdos.djgpp Subject: Re: ANSI C signal definitions Date: 8 May 96 10:08:08 +0200 Organization: University of Cape Town Lines: 38 Message-ID: <1996May8.100808@uctvms.uct.ac.za> References: NNTP-Posting-Host: uctvms.uct.ac.za To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article , Orlando Andico writes: > On 7 May 1996, Barry A Giffel wrote: > > >> Next, if SIGINT should not be defined, what's the best way to trap >> this signal. When a user presses Control-C, the SIGINT signal is >> generated, I need to be able to catch this signal and run a signal >> handler routine before exiting. > > > The naive solution if you're using Unix is just to set up a signal > handler for the appropriate signal: > > void sighandler (int signal) > { > /* do whatever */ > } > and then in your main code > > signal (SIGINT, sighandler); > at least, that should work. I'm not too sure under DJGPP because of all > the glitches associated with DOS. But since v2 aims for POSIX compliance, > it should support this behavior. > As far as I know, this will work under DJGPP v2.0 also, but it is dependant on the DPMI server running. Windows and QDPMI may handle the signals differently. I think CSDPMI works fine though, and trapping Ctrl-C is as easy as installing a signal handler. Allegro used to use Ctrl-C as a "hard break" to stop one's program, but now uses Ctrl-Alt-Del, although I don't think signals were used for this (Shawn ?) One should be aware that the Ctrl-C signal will not work 100% of the time, depending on DPMI ... Adios Mark Wodrich.