Register the signal handler before opening the socket that is closed by it.
This commit is contained in:
parent
ca3452402a
commit
5a1a3d1fcb
1 changed files with 6 additions and 5 deletions
11
netcalc.c
11
netcalc.c
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue