lichtjiang
Programmer
I have a server using unix domain socket. It works in a standard way: listening for requests and accepting each of them by running a separater thread for it:
while(true){
int clientsocket;
clientsocket=accept(serversocket, NULL, NULL);
ClientHandler * ch = new ClientHandler(someparameters, clientsocket);
ch->start();
}
So, how to terminate this server gracefully? I think some signal handler can be used for this purpose though I haven't done so and it's ok to do "kill -TERM pid" w/o the signal is handled by the server. But since there is a lot of cleanning work to do for each socket connection, this is not something recommended. Any idea or suggestion? Thanks!
while(true){
int clientsocket;
clientsocket=accept(serversocket, NULL, NULL);
ClientHandler * ch = new ClientHandler(someparameters, clientsocket);
ch->start();
}
So, how to terminate this server gracefully? I think some signal handler can be used for this purpose though I haven't done so and it's ok to do "kill -TERM pid" w/o the signal is handled by the server. But since there is a lot of cleanning work to do for each socket connection, this is not something recommended. Any idea or suggestion? Thanks!