diff --git a/src/Makefile.am b/src/Makefile.am index e8a082f2..088bb295 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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) diff --git a/src/api.c b/src/api.c index 2854107b..c80dba91 100644 --- a/src/api.c +++ b/src/api.c @@ -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; diff --git a/src/finit.c b/src/finit.c index abcbe9f1..727abb07 100644 --- a/src/finit.c +++ b/src/finit.c @@ -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); diff --git a/src/watchdog.h b/src/watchdog.h index 4366a1b9..468dca6d 100644 --- a/src/watchdog.h +++ b/src/watchdog.h @@ -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