Xref: news2.mv.net comp.os.msdos.djgpp:892 Newsgroups: comp.os.msdos.djgpp From: kunst AT natlab DOT research DOT philips DOT com (Pieter Kunst) Subject: Re: signal Sender: news AT natlab DOT research DOT philips DOT com (USENET News System) Message-ID: Date: Thu, 8 Feb 1996 08:29:11 GMT References: Organization: Philips Research Laboratories, Eindhoven, The Netherlands Lines: 37 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article cameronbuschardt writes: >I sorry to waste your time, could someone show me how to use SIGNAL(Note: >NOT THE DECLARATION...)??? Thanx... #include #include #include #include /* sleep() */ typedef void (*PFVI)(int); void onintr (void) { static int nr = 0; signal (SIGINT, (PFVI) onintr); /* reinstall ^c handler */ printf ("CTRL-C pressed...\n"); if (++nr >= 3) exit(1); } int main() { int i; if (signal (SIGINT, SIG_IGN) != SIG_IGN) /* install ^c handler */ signal (SIGINT, (PFVI) onintr); printf ("Hit CRTL-C 3 times to stop this program:\n"); for (i=1; i<=60; i++) { printf ("%3d\n", i); sleep (1); } return 0; }