delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/05/16/01:15:05

Date: Mon, 16 May 94 00:36:51 EDT
From: peprbv AT cfa0 DOT harvard DOT edu (Bob Babcock)
To: shc AT netcom DOT com
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Trapping Ctrl-C
Reply-To: babcock AT cfa DOT harvard DOT edu

> Some of these apps, however, need a way to trap ctrl-c so they can clean up
> before exit.  Go32 seems to catch this, itself, and bails with a comment.

Here's how I handle control-c in a djgcc program.  To some extent, the way I
do things is the same as I do under other environments, so not everything I
do may be necessary, and there may be alternatives.

1. At startup, I call _go32_want_control_break(1);

2. I call ctrlbrk(cbreak); where cbreak is

#define DO_NOT_ABORT 1
int cbreak(void)
   {
   Ctlchit = TRUE;
   return(DO_NOT_ABORT);
   }

3. I read the keyboard using int 0x21, ah=6, dl=0xff which does not do a
control-c check or with int 0x16.

At various points, I check global variable Ctlchit to see if I need to abort
the current operation.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019