mirror of
https://github.com/troglobit/finit.git
synced 2026-10-11 17:02:42 +07:00
Add support for registering a watchdog daemon
This patch adds initial support for registering a watchdog daemon with Finit. Needed for situations when you want the system to actually be rebooted by the watchdog timer (WDT) circuitry rather than the kernel. The initctl API has been extended with a INIT_CMD_WDOG_HELLO command that is used to both register and "ping" Finit periodically. As long as Finit responds (with an ACK) the watchdog daemon knows Finit is alive. At shutdown Finit stops all services (except kernel threads and daemons marked with @ in the first character of their process name) and, if a watchdog has registered, SIGPWR is sent to it when Finit has finished unmounting etc., just prior to kernel reboot/halt/poweroff. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -323,6 +323,19 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
|
||||
_d("Client failed reading ACK");
|
||||
goto leave;
|
||||
|
||||
case INIT_CMD_WDOG_HELLO:
|
||||
if (rq.runlevel <= 0) {
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (wdogpid > 0 && wdogpid != rq.runlevel) {
|
||||
kill(wdogpid, SIGTERM);
|
||||
do_sleep(1);
|
||||
}
|
||||
wdogpid = rq.runlevel;
|
||||
break;
|
||||
|
||||
default:
|
||||
_d("Unsupported cmd: %d", rq.cmd);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user