Mail Archives: djgpp-workers/1996/10/20/08:01:21
On Thu, 17 Oct 1996, John M. Aldrich wrote:
> But an odd thing happened when I was testing: if I pressed Ctrl-C, the
> program exited instantly; while if I pressed Ctrl-Break, the system
> would wait for another keystroke before exiting. Is this an artifact of
> using the conio functions (cgets, getch) instead of stdio? As I recall,
> when SIGINT is not handled, both keystrokes cause immediate
> termination. FYI, it happened under both Windoze and CWSDPMI.
Recall that the signals aren't handled until your program is back in
protected mode. When your program waits for a keystroke, it will get
Ctrl-C immediately (that's a keystroke, right?), switch to PM and get an
exception. Ctrl-Break, OTOH, is not a keystroke (you can never get it by
calling `getch'), so your program continues to be parked inside a
real-mode BIOS call issued by `getch' until it gets a *real* keystroke;
then it switches to PM--and the rest is history.
> BTW, is the fact that a generated SIGINT terminates ALL programs in an
> execution chain simultaneously unless one of them handles it a feature
> or a bug? Just curious...
It's a feature. Unix works in this way (i.e., the parent gets the
signals of its children unless it takes specific action not to), so DJGPP
does that also, since it's relatively easy. The latest port of GNU Make
3.75 uses this to correctly say "Interrupt" when the compilation is
interrupted, just like on Unix.
Note that, unlike Unix, only SIGINT works this way; other signals (such
as SIGFPE) don't.
- Raw text -