Register the signal handler before opening the socket that is closed by it.

This commit is contained in:
tim.schubert@tu-bs.de 2016-10-30 02:37:19 +02:00
parent ca3452402a
commit 5a1a3d1fcb

View file

@ -275,6 +275,12 @@ int client()
int main(int argc, char *argv[])
{
SOCKFD = 0;
struct sigaction action;
memset(&action, 0, sizeof(struct sigaction));
action.sa_handler = cleanup;
sigaction(SIGTERM, &action, NULL);
char* host = NULL;
char* port = "5000";
int afamiliy = AF_UNSPEC;
@ -310,11 +316,6 @@ int main(int argc, char *argv[])
return 1;
}
struct sigaction action;
memset(&action, 0, sizeof(struct sigaction));
action.sa_handler = cleanup;
sigaction(SIGTERM, &action, NULL);
if (CLIENT) {
connectclient(ainfo);
if (client() == -1) {