mirror of
https://github.com/troglobit/finit.git
synced 2026-10-10 16:52:39 +07:00
Follow-up to 18ab7d3: restore start of built-in watchdogd
This patch restores the start of the built-in/bundled watchdogd. It is
tracked in the `wdog` variable and handled as an exception at shutdown.
This is also a follow-up to 7b74c99, ensuring that we only kill/stop the
built-in watchdog, not any external. External ones can register to be
the controlling watchdogd in the system -- Finit is not the arbiter for
singletons, this is up to the system engineer.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+8
-9
@@ -7,21 +7,21 @@ else
|
||||
AM_LDFLAGS = -export-dynamic
|
||||
endif
|
||||
|
||||
sbin_PROGRAMS = finit initctl
|
||||
|
||||
sbin_PROGRAMS = finit initctl
|
||||
pkglibexec_PROGRAMS =
|
||||
finit_pkglibdir = $(pkglibdir)
|
||||
finit_pkglib_SCRIPTS = rescue.conf sample.conf
|
||||
|
||||
if WATCHDOGD
|
||||
pkglibexec_PROGRAMS = watchdogd
|
||||
pkglibexec_PROGRAMS += watchdogd
|
||||
endif
|
||||
|
||||
if LOGIT
|
||||
pkglibexec_PROGRAMS = logit
|
||||
logit_SOURCES = logit.c logrotate.c
|
||||
logit_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
|
||||
logit_CFLAGS += $(lite_CFLAGS)
|
||||
logit_LDADD = $(lite_LIBS)
|
||||
pkglibexec_PROGRAMS += logit
|
||||
logit_SOURCES = logit.c logrotate.c
|
||||
logit_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
|
||||
logit_CFLAGS += $(lite_CFLAGS)
|
||||
logit_LDADD = $(lite_LIBS)
|
||||
endif
|
||||
|
||||
finit_SOURCES = api.c cgroup.c cgroup.h \
|
||||
@@ -71,7 +71,6 @@ REBOOT_LNKS = reboot shutdown halt poweroff suspend
|
||||
if WATCHDOGD
|
||||
watchdogd_SOURCES = watchdog.c watchdog.h
|
||||
watchdogd_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
|
||||
#log.c log.h
|
||||
endif
|
||||
|
||||
# Hook in install to add finit and reboot symlink(s)
|
||||
|
||||
@@ -270,10 +270,10 @@ static void send_svc(int sd, svc_t *svc)
|
||||
|
||||
static void api_cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
int sd, lvl;
|
||||
svc_t *svc;
|
||||
static svc_t *iter = NULL;
|
||||
struct init_request rq;
|
||||
int sd, lvl;
|
||||
svc_t *svc;
|
||||
|
||||
sd = accept(w->fd, NULL, NULL);
|
||||
if (sd < 0) {
|
||||
@@ -394,13 +394,17 @@ static void api_cb(uev_t *w, void *arg, int events)
|
||||
break;
|
||||
}
|
||||
|
||||
/* 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 && wdog != svc) {
|
||||
char name[32];
|
||||
|
||||
svc_ident(svc, name, sizeof(name));
|
||||
logit(LOG_NOTICE, "Handing over wdog ctrl from %s[%d] to %s[%d]",
|
||||
svc_ident(wdog, NULL, 0), wdog->pid, name, svc->pid);
|
||||
|
||||
if (wdog->protect) {
|
||||
wdog->protect = 0;
|
||||
wdog->runlevels = 0;
|
||||
logit(LOG_NOTICE, "Stopping and deleting built-in watchdog.");
|
||||
stop(wdog);
|
||||
svc_del(wdog);
|
||||
}
|
||||
}
|
||||
wdog = svc;
|
||||
|
||||
@@ -549,6 +549,14 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
conf_init(&loop);
|
||||
|
||||
/*
|
||||
* Start built-in watchdogd as soon as possible, if enabled
|
||||
*/
|
||||
if (which(FINIT_LIBPATH_ "/watchdogd")) {
|
||||
service_register(SVC_TYPE_SERVICE, "[123456789] name:watchdog :finit " FINIT_LIBPATH_ "/watchdogd -- Finit watchdog daemon", global_rlimit, NULL);
|
||||
wdog = svc_find_by_nameid("watchdog", "finit");
|
||||
}
|
||||
|
||||
/* Base FS up, enable standard SysV init signals */
|
||||
sig_setup(&loop);
|
||||
|
||||
|
||||
@@ -26,12 +26,6 @@
|
||||
#define WDT_DEVNODE "/dev/watchdog"
|
||||
#define WDT_TIMEOUT 30
|
||||
|
||||
#ifdef BUILTIN_WATCHDOG
|
||||
int watchdog(char *progname);
|
||||
#else
|
||||
#define watchdog(progname) 0
|
||||
#endif /* BUILTIN_WATCHDOG */
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
|
||||
Reference in New Issue
Block a user