I'm working on a server-like program in xcode, and I want it to shut down gracefully between debug runs. Basically the following line is not working
std::signal(SIGKILL, [](int){
printf("got sigkill here!\n");
//shut-down code here
});
I've tried trapping other signals, but so far SIGINT, SIGTERM and SIGABRT have not worked. How is xcode terminating the program, if it prints
Program ended with exit code: 9
to the console?
EDIT Apparently SIGKILL can not be caught, see this wikipedia entry.
In contrast to SIGTERM and SIGINT, this signal cannot be caught or ignored, and the receiving process cannot perform any clean-up upon receiving this signal