Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote a function to catch the SIGINT in this way,
but each time the system still goes as the default function .

Here is the code :
in the main func:
C++
(void) signal(SIGINT, network_stop);


and in network_stop:
C++
void network_stop(int sig) {
  //signal(SIGINT, network_stop);
  close (overlay_conn);

}


anything wrong !?
Posted
Comments
TRK3 11-May-12 18:28pm    
What you show looks fine. The problem may be somewhere else. Try it with the simplest possible example and see if it works.

See this site:
http://www.alexonlinux.com/signal-handling-in-linux

It has a very simple example that should work. Copy it and compile it to verify it works on your system. (It might not, in which case it's a problem with your OS or toolchain implementing signal in a non standard way.) If it does work, then gradually add to the working example to make it more like your non-working version and see what change breaks it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900