X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd.c;fp=postlicyd.c;h=03675ad3bd382c246dd576bde4a2ccb50d75df6e;hb=cde61dd0b59b0f3f3b3afefafd045f8d75b32975;hp=d980d20f97e07a011665c08db2c640535e1a1d9b;hpb=4b706468477ccccc11d9aeb3bccdbe67b777c298;p=apps%2Fpfixtools.git diff --git a/postlicyd.c b/postlicyd.c index d980d20..03675ad 100644 --- a/postlicyd.c +++ b/postlicyd.c @@ -33,7 +33,36 @@ * Copyright © 2006 Pierre Habouzit */ +#include +#include +#include +#include + +#include "job.h" + +bool cleanexit = false; + +void shutdown(void) +{ + syslog(LOG_INFO, cleanexit ? "Stopping..." : "Unclean exit..."); + job_shutdown(); + closelog(); +} + int main(void) { + if (atexit(shutdown)) { + fputs("Cannot hook my atexit function, quitting !\n", stderr); + return EX_CONFIG; + } + + openlog("postlicyd", LOG_PID, LOG_MAIL); + job_initialize(); + syslog(LOG_INFO, "Starting..."); + + job_loop(); + + cleanexit = true; + shutdown(); return 0; }