I'm developing a server application and want to use SIGINT for killing application. Although I know 2 ways, I'm not sure which are good way to kill this application.
Are there any better ways to handle SIGING?
int main() {
startServer();
1. while(true) {sleep(3); if(sigFlag) break;}
2. std::getline(std::cin, param);
stopServer();
return 0;
}
Source: http://www.thegeekstuff.com/2012/03/catch-signals-sample-c-code/
Instead of printf use return or exit