Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>control-c handling</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Control-C Handling

   It is always difficult to handle the Ctrl-C and Ctrl-Break interrupts
   properly under MS-DOS. They can cause your program to abort when you
   least expect it, with disastrous results. Add to this the difficulty of
   supporting interrupt handlers on DOS extended platforms and under
   UNIX, and you have a major portability issue all centering around a trivial
   problem.

   The controlc_ functions provide a solution to this problem. They are
   portable across all of the platforms Zortech supports. This code will work
   under DOS, Rational Systems DOS16RM, Phar Lap s DOS386 and our
   own 286 and 386 DOS extended platforms. They also work under OS/2 and
   UNIX.

   These functions utilize the following global variable:

       void (* _far _cdecl _controlc_handler)(void);

   To use them, install a pointer to your control c/break handler in
   _controlc_handler, and then call controlc_open() to activate it.

Example 

   void _far _cdecl myhandler(void)
   {
       controlc_occurred = 1;
       // don't call any functions here that might call DOS
       // because this is an interrupt service routine
       // and DOS is not reentrant.
   }

   void main(void)
   {
       // notify your custom handler
       _controlc_handler = myhandler;


       // install control C/control BREAK handler
      controlc_open();

       // remove control C/control BREAK handler
       controlc_close();
   }





Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson