Compare commits

..
14 Commits
Author SHA1 Message Date
Joachim Wiberg 6f6267f3b3 When collecting a script or unregistering a service, cancel timeouts
Both service and sysv stanzas support a cleanup:script (since v4.10), with an
optional timeout.  These timers must be stopped when collecting a PID for an
svc_t, or when unregistering an svc_t, otherwise the timer callback will be
continuously called, reporting "spurious problem", and cause 100% CPU usage.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 16:49:34 +02:00
Joachim Wiberg dec89d4054 Minor, drop __func__ from dbg() statements
The dbg() macro already includes __func__ as the first text string in
the format string.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 16:48:38 +02:00
Joachim Wiberg 193e114596 Enable libsystemd replacement lib for tests also in distcheck stage
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 16:02:42 +02:00
Joachim Wiberg 1be67c434e Update ChangeLog and bump version for v4.14 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 15:07:45 +02:00
Joachim Wiberg 4f8dab75b2 Update test helper and all workflows to enble libsystemd build
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 14:43:25 +02:00
Joachim Wiberg 37d063fd3b Build --without-libsystemd by default
Many packages fail to detect that this replacement libsystemd does not
support the logging API (yet), so let's disable it by default.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 13:12:43 +02:00
Joachim Wiberg 97be3da126 Minor doc styling fixes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 12:54:06 +02:00
Joachim Wiberg e7f97f8264 Fix state machine ordering issue
This patch fixes an ordering issue where the configuration generation is
stepped before all old/disabled services had been stopped.  Finit should
ensure disabled services are stopped before entering the next generation.

If the genation is stepped first, all conditions are put in "flux" state,
so, e.g, a podman container running as a sysv service may lock-up until
it is killed by Finit.  Found in the Infix OS project.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 12:47:43 +02:00
Joachim Wiberg 6415aeebac Ensure sysv 'stop' command has same env. as 'start'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 10:17:19 +02:00
Mattias Barthel e69200ea43 Add exit status/signal info when a process dies
Signed-off-by: Mattias Barthel <mattiasbarthel@gmail.com>
2025-08-29 10:12:58 +02:00
Joachim Wiberg 26d5018224 Allow kill delay up to five minutes for debug
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 10:02:36 +02:00
Joachim Wiberg 1b7699ca93 Expand norespawn grasp to service_retry()
The norespawn hack pause Finit while a developer debugs the system.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 10:00:25 +02:00
Joachim Wiberg 8eab099f09 Minor, encase script + args in '' for debug help
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-08-29 09:58:10 +02:00
Joachim Wiberg c7c5426586 Fix #449: alsa plugin ftbfs
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-07-22 15:46:46 +02:00
12 changed files with 78 additions and 21 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ jobs:
run: |
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \
--enable-x11-common-plugin --enable-testserv-plugin --with-watchdog \
--with-keventd \
--with-keventd --with-libsystemd \
CFLAGS="-fsanitize=address -ggdb"
make -j3 clean
make -j3 V=1
+2 -1
View File
@@ -66,7 +66,8 @@ jobs:
- name: Configure
run: |
./autogen.sh
./configure --prefix= --enable-x11-common-plugin --with-watchdog --with-keventd
./configure --prefix= --enable-x11-common-plugin --with-watchdog \
--with-keventd --with-libsystemd
- name: Build
run: |
export PATH=`pwd`/coverity/bin:$PATH
+4 -3
View File
@@ -39,9 +39,10 @@ jobs:
- name: Creating Makefiles ...
run: |
./autogen.sh
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \
--enable-x11-common-plugin --enable-testserv-plugin --with-watchdog \
--with-keventd
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc \
--localstatedir=/var --enable-x11-common-plugin \
--enable-testserv-plugin --with-watchdog \
--with-keventd --with-libsystemd
- name: Enable unprivileged userns (unshare)
run: |
sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0
+1 -1
View File
@@ -43,4 +43,4 @@ release: distcheck
DISTCHECK_CONFIGURE_FLAGS = --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
--enable-testserv-plugin --enable-x11-common-plugin \
--with-watchdog --with-keventd --with-fstab=/etc/fstab \
--with-bash-completion-dir=no
--with-libsystemd --with-bash-completion-dir=no
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT([Finit], [4.13], [https://github.com/troglobit/finit/issues],
AC_INIT([Finit], [4.14], [https://github.com/troglobit/finit/issues],
[finit], [https://troglobit.com/projects/finit/])
AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign subdir-objects])
@@ -171,7 +171,7 @@ AC_ARG_WITH(watchdog,
AC_ARG_WITH(libsystemd,
AS_HELP_STRING([--with-libsystemd], [Build replacement libsystemd library, default: yes]),
[with_libsystemd=$withval], [with_libsystemd=yes])
[with_libsystemd=$withval], [with_libsystemd=no])
AC_ARG_WITH(hook-scripts-path,
AS_HELP_STRING([--with-hook-scripts-path=DIR], [Base directory for hook scripts, default $libexecdir/finit/hook]),
+19
View File
@@ -4,6 +4,25 @@ Change Log
All relevant changes are documented in this file.
[4.14][] - 2025-08-29
---------------------
Minor bug fix release.
### Changes
- Add exit status/signal info when a process dies, by Mattias Berthel
- Extend `service kill:SEC` to support up to 300 sec.
- Extend `norespawn` debug to cover `service_retry()`
- Build *without* libsystemd replacement by default
### Fixes
- Fix #449: ALSA plugin fail-to-build-from-source
- Fix `sysv` stop command process environment, should be same as start
- Fix state machine ordering issue: enter new config generation *after*
services disabled in previous generation have been stopped
[4.13][] - 2025-07-10
---------------------
+11
View File
@@ -0,0 +1,11 @@
.md-header__topic:first-child {
font-weight: 500;
font-style: italic;
}
.md-header__title {
font-size: 1.1rem;
font-style: italic;
font-weight: 500;
line-height: 2.6rem;
}
+3 -1
View File
@@ -1,4 +1,4 @@
site_name: doc/
site_name: Documentation
site_description: Fast Init for Linux Systems
site_url: https://troglobit.github.io/finit/
repo_url: https://github.com/troglobit/finit
@@ -6,6 +6,8 @@ repo_name: troglobit/finit
copyright: Copyright &copy; 2008-2025 Joachim Wiberg
docs_dir: doc/
edit_uri: edit/master/doc/
extra_css:
- extra.css
exclude_docs: |
TODO.md
+1
View File
@@ -27,6 +27,7 @@
# include <lite/lite.h>
#endif
#include "conf.h"
#include "finit.h"
#include "helpers.h"
#include "plugin.h"
+27 -9
View File
@@ -88,7 +88,7 @@ static void service_timeout_cb(uev_t *w, void *arg, int events)
svc_t *svc = arg;
if (UEV_ERROR == events) {
dbg("%s(): spurious problem, svc %s.", __func__, svc_ident(svc, NULL, 0));
dbg("%s: spurious problem", svc_ident(svc, NULL, 0));
uev_timer_start(w);
return;
}
@@ -1147,10 +1147,11 @@ int service_stop(svc_t *svc)
args[i++] = "stop";
args[i] = NULL;
switch (fork()) {
switch (service_fork(svc)) {
case 0:
setsid();
redirect(svc);
setsid();
sig_unblock();
exec_runtask(args[0], &args[1]);
_exit(0);
break;
@@ -1420,9 +1421,9 @@ static void parse_killdelay(svc_t *svc, char *delay)
const char *errstr;
long long sec;
sec = strtonum(delay, 1, 60, &errstr);
sec = strtonum(delay, 1, 300, &errstr);
if (errstr) {
errx(1, "%s: killdelay %s is %s (1-60)", svc_ident(svc, NULL, 0), delay, errstr);
errx(1, "%s: killdelay %s is %s (1-300)", svc_ident(svc, NULL, 0), delay, errstr);
return;
}
@@ -1464,7 +1465,7 @@ static void parse_script(svc_t *svc, char *type, char *script, int *tmo, char *b
found = which(path);
if (!found) {
logit(LOG_WARNING, "%s:%s is missing or not executable, skipping.", type, path);
logit(LOG_WARNING, "%s:'%s' is missing or not executable, skipping.", type, path);
goto err;
}
free(found);
@@ -2097,6 +2098,7 @@ void service_unregister(svc_t *svc)
return;
service_stop(svc);
service_timeout_cancel(svc);
for (c = strtok(svc->cond, ","); c; c = strtok(NULL, ","))
devmon_del_cond(c);
@@ -2136,6 +2138,10 @@ void service_monitor(pid_t lost, int status)
: (svc->state == SVC_CLEANUP_STATE
? svc->cleanup_script
: svc->pre_script)), lost, ok, sig, rc);
/* Prevent: spurious problem from timeout callback */
service_timeout_cancel(svc);
/* Kill all children in the same proess group, e.g. logit */
dbg("Killing lingering children in same process group ...");
kill(-svc->pid, SIGKILL);
@@ -2467,6 +2473,10 @@ static void service_retry(svc_t *svc)
int timeout;
service_timeout_cancel(svc);
if (is_norespawn())
return;
if (svc->respawn) {
dbg("%s crashed/exited, respawning ...", svc_ident(svc, NULL, 0));
svc_unblock(svc);
@@ -2518,8 +2528,13 @@ static void service_retry(svc_t *svc)
timeout = ((*restart_cnt) <= (svc->restart_max / 2)) ? 2000 : 5000;
/* If a longer timeout was specified in the conf, use that instead. */
svc->restart_tmo = max(svc->restart_tmo, timeout);
logit(LOG_CONSOLE|LOG_WARNING, "Service %s[%d] died, restarting (retry in %d msec) (attempt: %d/%d)",
svc_ident(svc, NULL, 0), svc->oldpid, svc->restart_tmo, *restart_cnt, svc->restart_max);
logit(LOG_CONSOLE|LOG_WARNING, "Service %s[%d] died (%s%d), restarting (retry in %d msec) (attempt: %d/%d)",
svc_ident(svc, NULL, 0), svc->oldpid,
WIFEXITED(svc->status) ? "with exit status: " : "by signal: ",
WIFEXITED(svc->status) ? WEXITSTATUS(svc->status) : WTERMSIG(svc->status),
svc->restart_tmo,
*restart_cnt,
svc->restart_max);
svc_unblock(svc);
service_step(svc);
@@ -2771,6 +2786,9 @@ restart:
if (sm_in_reload())
break;
if (is_norespawn())
break;
/* Don't start if it conflicts with something else already started */
if (svc_conflicts(svc)) {
logit(svc->nowarn ? LOG_DEBUG : LOG_INFO,
@@ -3141,7 +3159,7 @@ static void service_interval_cb(uev_t *w, void *arg, int events)
(void)arg;
if (UEV_ERROR == events) {
dbg("%s(): spurious problem, restarting.", __func__);
dbg("spurious problem, restarting.");
uev_timer_start(w);
return;
}
+5 -2
View File
@@ -359,6 +359,8 @@ restart:
break;
case SM_RELOAD_CHANGE_STATE:
sm.in_reload = 1;
/* First reload all *.conf in /etc/finit.d/ */
conf_reload();
@@ -367,10 +369,11 @@ restart:
* let all affected services move to WAITING/HALTED
*/
dbg("Stopping services not allowed after reconf ...");
sm.in_reload = 1;
cond_reload();
service_step_all(SVC_TYPE_ANY);
/* Step the generation ... */
cond_reload();
sm.state = SM_RELOAD_WAIT_STATE;
break;
+2 -1
View File
@@ -25,7 +25,8 @@ if [ "$run_make" -eq 1 ]; then
fi
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \
--enable-x11-common-plugin --with-watchdog --with-keventd \
--enable-x11-common-plugin --enable-testserv-plugin --with-watchdog \
--with-keventd --with-libsystemd \
CFLAGS='-fsanitize=address -ggdb'
if [ "$run_make" -eq 1 ]; then