Skip to content

Commit

Permalink
Merge pull request #46 from eric-ch/stable-8-oxt-1352
Browse files Browse the repository at this point in the history
STABLE-8: OXT-1352: xcpmd: Remove pidfile on exit.
  • Loading branch information
jean-edouard authored Jun 21, 2018
2 parents a584107 + 134e177 commit ff06a14
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions xcpmd/src/xcpmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@
#include "rules.h"


void sighandler_term(int signal, short event, void *base)
{
(void) signal;
(void) event;
event_base_loopbreak(base);
}

int main(int argc, char *argv[]) {

int ret = 0;
struct event ev_sigterm;
struct event_base *ev_base;

#ifndef RUN_STANDALONE
openlog("xcpmd", 0, LOG_DAEMON);
Expand All @@ -55,7 +64,11 @@ int main(int argc, char *argv[]) {
xcpmd_log(LOG_INFO, "Starting XenClient power management daemon.\n");

//Initialize libevent library
event_init();
ev_base = event_init();

//SIGTERM handler.
evsignal_set(&ev_sigterm, SIGTERM, sighandler_term, ev_base);
evsignal_add(&ev_sigterm, NULL);

//Initialize xenstore.
if (xenstore_init() == -1) {
Expand Down Expand Up @@ -131,8 +144,7 @@ int main(int argc, char *argv[]) {
#ifndef RUN_STANDALONE
closelog();
#endif
unlink(XCPMD_PID_FILE);

return ret;
}


0 comments on commit ff06a14

Please sign in to comment.