Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Handling Ctr+c In C++ In Windowsxp (http://www.programmingforums.org/showthread.php?t=1412)

RoilO Dec 4th, 2004 6:05 AM

Hi,
I'm trying to disable/ignore the ctrl+c in a c++ program.
I did it alot on UNIX but somehow it doens't work on WindowsXP,
I'm using the right function and typedefs but still....nothing.

I'm doing something like:

void someFunction(int sigNum){
signal (SIGINT,somefunction);
cout<<"eh eh, you can't use ctrl+c"<<endl;
}

main(){
signal(SIGINT,somefunction);

/*
Shell program
*/
}

I debuged the code and it looks like it's doesn't get into the someFunction at all and terminates and program as if I didn't use the signal function.

Any ideas?
thanks a lot.

Eggbert Dec 4th, 2004 11:04 AM

I don't have any problems using this test program:
:

#include <iostream>
#include <csignal>

using namespace std;

void sig_handler ( int )
{
 signal ( SIGINT, sig_handler );
 cout<<"Interactive attention disabled"<<endl;
}

int main()
{
 signal ( SIGINT, sig_handler );

 while ( 1 )
  ;
}

Try it and see if you still have the same problem.


All times are GMT -5. The time now is 2:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC