TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Udo Van Den Heuvel
from: Rob Hamerling
date: 1996-07-05 22:13:34
subject: ctrl-c?

Referring to your msg of 02 Jul 1996:

Hi Udo,

 UVDH> How do I catch a CTRL-C so it doesn't cancel my program?

What about the following?


/* SIGNAL */

#include 
#include 
#include 

void handler(int sig)
{
  signal(SIGINT, handler);              /* re-instate */
  printf(" (this was a Ctrl-C or Ctrl-Break signal)");
  } 

int  main(void)
{
  int i;

  signal(SIGINT, handler);

  printf("Program processes Ctrl-C an Ctrl-Break itself!\n");
  i = 0;
  while (i != '!') {
    printf("Enter a character (! to stop): ");
    i = getch();
    printf("%c\n", i);
    }
  return 0;
  }


Cheers, Rob 
--- timEd/2 1.10+
* Origin: Root of Downsort, Netherlands [31-347-322423] (2:281/732)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 517 628 713/888 800/1
@PATH: 281/732 705 283/512 280/801 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.