I have a simple server that looks something like this:
void *run_thread(void *arg) {
}
int main() {
while (1) {
new_client = accept(socket, ...);
pthread_create(&thread, NULL, &run_thread, *thread_data*);
pthread_detach(thread);
}
close(socket);
exit(0);
)
Thus, when SIGINT or SIGTERM is received, I need to exit the main event loop to go to the cleanup code. Moreover, the main call expects an accept () call, so it cannot check any other variable to see if it should break ;.
, , : http://devcry.blogspot.com/2009/05/pthreads-and-unix-signals.html ( , ). , , : accept() , , break;?