--- mqtt/src/mqttd.c 2012/05/22 14:15:04 1.2.2.8 +++ mqtt/src/mqttd.c 2012/06/26 14:51:33 1.2.2.10 @@ -43,6 +43,7 @@ sigHand(int sig) } ioLIBERR(cfg); + case SIGINT: case SIGTERM: ioDEBUG(1, "Terminate MQTT service in progress"); Kill++; @@ -97,8 +98,9 @@ main(int argc, char **argv) for (i = 0; i < 3; i++) if (!mqttLoadRTLM(&cfg, i)) { printf("Error:: Can't load RTL module\n"); - while (i--) - mqttUnloadRTLM(i); + mqttUnloadRTLM(acc); + mqttUnloadRTLM(pub); + mqttUnloadRTLM(logg); cfgUnloadConfig(&cfg); closelog(); return 2; @@ -119,6 +121,7 @@ main(int argc, char **argv) goto end; } + if (mqttMkDir(&cfg)) { printf("Error:: in statedir #%d - %s\n", errno, strerror(errno)); ret = 3; @@ -156,6 +159,7 @@ main(int argc, char **argv) sigemptyset(&sa.sa_mask); sa.sa_handler = sigHand; sigaction(SIGHUP, &sa, NULL); + sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGCHLD, &sa, NULL); sigaction(SIGPIPE, &sa, NULL); @@ -190,9 +194,10 @@ end: /* free all resources */ call.CloseLOG(logg); call.ClosePUB(pub); call.CloseACC(acc); - for (i = 0; i < 3; i++) - mqttUnloadRTLM(i); - closelog(); + mqttUnloadRTLM(acc); + mqttUnloadRTLM(pub); + mqttUnloadRTLM(logg); cfgUnloadConfig(&cfg); + closelog(); return ret; }