Mail Archives: djgpp/1997/01/13/07:17:37
Alaric Dailey (alaric AT oasis DOT novia DOT net) wrote:
: Ok Eli here is the post you asked for explaining how to call this ctrlbrk
: function (including the change to "signal")
:
: #include <stdio.h>
:
: void ctrlbrk(fptr)
: int (*fptr)();
: {
: int signal (int, int (*fptr)());
: signal (SIGINT, fptr);
: }
:
: void teminate(void)
: {
: 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!");
: }
:
: 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
Ok guys here is a good one for you. I recieved a respone to check where
SIGINT was defined and include that .h file (duh, I feel stupid now, why
did I think of that? ) so I did. that header file is <signal.h>, once you
do that the compiler complian s about a double definition for "signal".
If you just do the define "#define SIGINT 295" and add an "exit (0);" to
the end of the terminate function, it compiles and runs perfectly so how
do I avoid the double definition problem when "signal.h" gets included???!?!?
--
####################################################
We go left, right, left, right, left-
They're left in the right again.
We go right, left, right, left, right-
We've no rights left anymore.
-Martin Walkyier (Skyclad)
- Raw text -