delorie.com/archives/browse.cgi | search |
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: | <DMG7Kn.2rq@natlab.research.philips.com> |
Date: | Thu, 8 Feb 1996 08:29:11 GMT |
References: | <DMDxpG DOT 2v6 AT granite DOT mv DOT net> |
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 <DMDxpG DOT 2v6 AT granite DOT mv DOT net> cameronbuschardt <c027319 AT email4 DOT starnetinc DOT com> writes: >I sorry to waste your time, could someone show me how to use SIGNAL(Note: >NOT THE DECLARATION...)??? Thanx... #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> /* 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; }
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |