mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
Refactor wdog tracking and hand-over to use svc_t instead of PID
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
40db4f4f58
commit
a487a30814
4 files changed
+31
-16
No files matched your search
@@ -44,6 +44,7 @@
|
||||
#include "service.h"
|
||||
#include "util.h"
|
||||
|
||||
extern svc_t *wdog;
|
||||
static uev_t api_watcher;
|
||||
|
||||
static int call(int (*action)(svc_t *), char *buf, size_t len)
|
||||
@@ -340,13 +341,23 @@ static void api_cb(uev_t *w, void *arg, int events)
|
||||
break;
|
||||
}
|
||||
|
||||
if (wdogpid > 0 && wdogpid != rq.runlevel) {
|
||||
_d("Sending SIGTERM to %d", wdogpid);
|
||||
kill(wdogpid, SIGTERM);
|
||||
do_sleep(1);
|
||||
_e("Request to hand-over wdog ... to PID %d", rq.runlevel);
|
||||
svc = svc_find_by_pid(rq.runlevel);
|
||||
if (!svc) {
|
||||
logit(LOG_ERR, "Cannot find PID %d, not registered.", rq.runlevel);
|
||||
break;
|
||||
}
|
||||
_d("wdog was %d, now %d is in charge", wdogpid, rq.runlevel);
|
||||
wdogpid = rq.runlevel;
|
||||
|
||||
/* Disable and allow Finit to collect bundled watchdog */
|
||||
if (wdog) {
|
||||
logit(LOG_NOTICE, "Stopping and removing %s (PID:%d)", wdog->cmd, wdog->pid);
|
||||
stop(wdog);
|
||||
if (wdog->protected) {
|
||||
wdog->protected = 0;
|
||||
wdog->runlevels = 0;
|
||||
}
|
||||
}
|
||||
wdog = svc;
|
||||
break;
|
||||
|
||||
case INIT_CMD_SVC_ITER:
|
||||
|
||||
Reference in new issue
Block a user