Mail Archives: djgpp/1997/01/13/11:08:40
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 <stdio.h>
#include <signal.h>
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/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Raw text -