diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -5,8 +5,10 @@ #include <stdarg.h> #include <printf.h> #include <ctype.h> +#include <math.h> #include <time.h> #include <unistd.h> +#include <signal.h> #include <pthread.h> #include <stdatomic.h> #include <i18n.h> @@ -46,6 +48,9 @@ char sc_securitytxt[] = "# This content information is provided by the developer #include <api.c> #include <httpd.c> /* this is new in my programs. I am now using _sizeof for the actual alloced size of the array and _length for the count of elements in array. this is done to decrease number of calls to realloc&amis */ +void sc_signalhander (int s) { + return; +} int main (int argc, char ** argv) { int rs = 0; struct sc_cache * c = sc_cache_init(); @@ -54,13 +59,19 @@ int main (int argc, char ** argv) { rs = 1; goto rc; } + xmlInitParser(); d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, SC_HTTP_PORT, NULL, NULL, &sc_httpd, c, MHD_OPTION_END); if (!d) { rs = 2; goto rc; } + signal(SIGTERM, sc_signalhander); + signal(SIGINT, sc_signalhander); pause(); + fprintf(stderr, "cleaning up!\n"); + fflush(stderr); rc: + xmlCleanupParser(); sc_cache_free(c); MHD_stop_daemon(d); return rs; |