delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/13/19:15:42

Date: Thu, 13 Jan 94 18:20:25 EST
From: peprbv AT cfa0 DOT harvard DOT edu (Bob Babcock)
To: pgf AT Cayman DOT COM
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: suppressing control-C?
Reply-To: babcock AT cfa DOT harvard DOT edu

> hi -- i got some mail from dj that implied it should be possible to
> suppress the interrupting action of control-C in my input stream.  anyone
> know how to do this?

Check the docs (libcref.i) for the functions _go32_want_ctrl_break and
_go32_was_ctrl_break_hit.

> on a related topic, how do i (or can i) install a critical error handler?

Allocate some DOS memory, copy code for a critical error handler into it,
point the (real mode) critical error vector at this code.  The handler
should either set a flag which you can check from protected mode (via
dosmemget) or do a real-mode callback.  Here's an example which I posted
a while back.  Responses pointed out that I don't check whether the
allocation of DOS memory succeeded.
------- cut here ------------
#include <stdio.h>
#include <wssindex.h>   /* defines LOGICAL and global variable Hard_error */
#include <dpmi.h>
#include <go32.h>

/* hardgcc - critical error handler for gcc
 */

static char handler[16] =
   {
   0x81, 0xe7, 0x7f, 0,       /* and di,7f         */
   0x47,                      /* inc di            */
   0x2e, 0x89, 0x3e, 0xe, 0,  /* mov cs:[0eh],di   */
   0xb8, 3, 0,                /* mov ax,3          */
   0xcf,                      /* iret              */
   0,0                        /* storage for error code */
   };
static LOGICAL handler_installed = FALSE;
static _go32_dpmi_seginfo new_handler_info, old_handler_info;

/* hardset - install the real-mode critical error handler
 */
void hardset(void)
   {
/* On first call, allocate some DOS memory and copy the handler into it
 */
   if(!handler_installed)
      {
      handler_installed = TRUE;
      new_handler_info.size = old_handler_info.size = 1;
      _go32_dpmi_allocate_dos_memory(&new_handler_info);
      dosmemput(handler, 16, new_handler_info.rm_segment * 16);
#ifdef DEBUG
      sprintf(Tempbuf, "Handler at segment %x", new_handler_info.rm_segment);
      error_msg(Tempbuf, 0);
#endif
      }
   _go32_dpmi_get_real_mode_interrupt_vector(0x24, &old_handler_info);
   _go32_dpmi_set_real_mode_interrupt_vector(0x24, &new_handler_info);
   clear_hard_error();
   return;
   }

/* hardclear - switch back to old critical error handler
 */
void hardclear(void)
   {
   if(handler_installed)
      _go32_dpmi_set_real_mode_interrupt_vector(0x24, &old_handler_info);
   return;
   }

/* clear_hard_error - clear any indication of a critical error
 */
void clear_hard_error(void)
   {
   short zero = 0;

   if(handler_installed)
      dosmemput(&zero, 2, new_handler_info.rm_segment * 16 + 14);
   Hard_error = 0;
   return;
   }

/* test_hard_err - test whether a critical error has occurred and return
   error code (0 if none or handler never installed).
 */
int test_hard_err(void)
   {
   short error_code;

   if(handler_installed)
      {
      dosmemget(new_handler_info.rm_segment * 16 + 14, 2, &error_code);
#ifdef DEBUG
      if(error_code)
         {
         sprintf(Tempbuf,"Critical error code is %d", error_code);
         error_msg(Tempbuf,0);
         }
#endif
      return(error_code);
      }
   return(0);
   }

- Raw text -


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