www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/13/07:17:37

From: alaric AT oasis DOT novia DOT net (Alaric Dailey)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: catching a CTRL C / Just for Eli and DJ Delorie
Date: 13 Jan 1997 05:11:29 GMT
Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
Lines: 51
Message-ID: <5bcg61$eep@nntp.novia.net>
References: <5b9r78$h1f AT nntp DOT novia DOT net> <5bb23s$6oq AT nntp DOT novia DOT net>
NNTP-Posting-Host: oasis.novia.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019