I've to handle the SIGHUP and the SIGPIPE signal in order to avoid that a CLIENT, connected via Socket TCP, closing the terminal (The [X] of the GUI) hadn't to close or crash the SERVER.
I've set on the client a sigup handler like this
void sighup()
{
signal(SIGHUP, SIG_IGN);
system("echo SIGHUP received>>log.txt");
close(socket);
exit(0);
}
On the server I've set a SIGPIPE handler like this
signal(SIGPIPE,SIG_IGN);
but, if the client close the windows of the terminal, the server loops.
Any idea? Thank you anyway for support