diff options
author | V.Krishn <vkrishn4@gmail.com> | 2020-02-19 02:27:39 +0530 |
---|---|---|
committer | V.Krishn <vkrishn4@gmail.com> | 2020-02-19 02:27:39 +0530 |
commit | 0551fb1a950ab26e48c6b85ec1acb935884551bc (patch) | |
tree | 46c14967b986ff6e90ac67d8358209e145a0db90 /sub_client.c | |
parent | da6bcb151f0465d060ac43c27a6cdcfc8e7e3dd5 (diff) | |
download | mqtt-dirpub-0551fb1a950ab26e48c6b85ec1acb935884551bc.tar.bz2 |
update to mosquitto-v1.6.8
Diffstat (limited to 'sub_client.c')
-rw-r--r-- | sub_client.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sub_client.c b/sub_client.c index 4662be8..8707d0d 100644 --- a/sub_client.c +++ b/sub_client.c @@ -46,7 +46,7 @@ int last_mid = 0; #ifndef WIN32 void my_signal_handler(int signum) { - if(signum == SIGALRM){ + if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){ process_messages = false; mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props); } @@ -360,6 +360,16 @@ int main(int argc, char *argv[]) goto cleanup; } + if(sigaction(SIGTERM, &sigact, NULL) == -1){ + perror("sigaction"); + goto cleanup; + } + + if(sigaction(SIGINT, &sigact, NULL) == -1){ + perror("sigaction"); + goto cleanup; + } + if(cfg.timeout){ alarm(cfg.timeout); } @@ -380,6 +390,7 @@ int main(int argc, char *argv[]) return rc; cleanup: + mosquitto_destroy(mosq); mosquitto_lib_cleanup(); client_config_cleanup(&cfg); return 1; |