Hi all,
I have built a TCP server which i need to shutdown nicely when some signals are received. My problem is this:
As a first approach i though of setting a global variable which would then cause the server to exit. But most of the times the server is blocked in the accept() call when the signal arrives so it is needed for one additional client to connect in order for the close to take effect. So now i throw an exception from the signal handler which is then causing the server to shutdown. Using exceptions however from within a signal handler is strongly discouraged as it may cause undefined behavior. Is there some more elegant solution for shutting down the server?
Thanks in advance,
verbal