From: Timo Saarinen Newsgroups: comp.os.msdos.djgpp Subject: Re: catching a CTRL C / Just for Eli and DJ Delorie Date: Mon, 13 Jan 1997 09:42:52 -0800 Organization: University of Kuopio / Library Lines: 45 Message-ID: <32DA741C.60A1@uku.fi> References: <5b9r78$h1f AT nntp DOT novia DOT net> <5bb23s$6oq AT nntp DOT novia DOT net> Reply-To: Timo DOT Saarinen AT uku DOT fi NNTP-Posting-Host: kryssi8.uku.fi Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Alaric Dailey wrote: [...] > The explaination is simple the program should do the while loop until you > hit ^C in which case it will call the function "terminate", any help > would be appreciated since I have not yet tried the change to "signal" yet > I will go see if that helps at all. > > TTFN Hi, I made some modifications to your source code and now it works well. Here it is: #include #include void terminate(int a); void ctrlbrk(void (*fptr)(int)) { signal (SIGINT, fptr); } void terminate(int a) { puts("I am doing clean up and exiting because you hit Contro-C"); exit (0); } int main() { ctrlbrk(terminate); // when ^c is hit call the cleanup funtion while (1) puts("I am running on and on and on and on!"); } Timo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Timo Saarinen, University of Kuopio / Library, Finland E-mail: Timo DOT Saarinen AT uku DOT fi Homepage: http://www.lut.fi/~tsaarine/ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-