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>
Now that we change runlevel at shutdown/reboot, we also need to restore
terse mode before calling the shutdown hooks, like before.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch replaces kill(-1, signo) with a more fine grained
do_kill(signo) that traverses each /proc/PID, skipping kernel
threads and special [0][0] == '@' processes.
The reason for this patch is not only future compliance with
freedesktop.org standards, but also a way of not killing any
critical processes at shutdown, e.g. mdadm or watchdogd.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The shutdown hook is supposed to run right before services start
receiving SIGTERM. Change due to previous refactor.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch moves both the definition and the call to bootclean() from
finit.c to the bootmisc plugin. We want to call bootclean() *after*
any /run and /var file systems have been mounted.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- New requirements section about what Finit expects from the system
- Remove commented out `udevadm settle` code, now in README
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
On systems with systemd-udev/udevadm the trigger addition of devices at
boot wrecks havoc of /dev/console. This patch forces Finit to go silent
by default on such systems. Far from ideal, but since the actual root
cause for this messup is unknown this will have to do for now.
Also, add a settle timeout of 120 sec to the udev device tree population.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch factors out the fgetint() fallback code for parsing
/etc/services and /etc/protocols. Useful on systems with a
malfunctioning C library.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Without trigger, kernel modules won't be loaded automatically. Also
devices are not managed. For example, i915 was not loaded after boot
and my network card was not renamed from wlan0 to wlp3s0, which means
it was not handled properly by udev.
Signed-off-by: Wang He <xw897002528@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch fixes a long-standing issue with how Finit handles shutdown,
reboot and poweroff -- and even runlevel changes to runlevel 0 and 6.
Prior to this patch sig.c:do_shutdown() was called immediately on any
of the above events, disregarding any services that a user might have
wanted to run as part of the shutdown/reboot.
With this change the handling is unified in all frontends to instead
do a runlevel change followed by the do_shutdown() action.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The /etc/nologin file must be set as soon as the runlevel change to
0/1/6 comes in, not when done with runlevel change and services have
been started, if any.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
As a last ditch effort to understand why an embedded system doesn't
boot, the operator should be able to see as much logs as possible
when enabling --debug mode on the kernel command line.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>