mirror of
https://github.com/troglobit/finit.git
synced 2026-11-17 19:30:29 +00:00
keventd: touch the PID file after SIGHUP
After a SIGHUP, from initctl reload or a changed service, Finit waits for a pid-notify daemon to recreate or touch its PID file to reassert readiness. keventd only reloaded its rules, so with a daemon-owned PID file it never did. Touch it with pidfile() after reloading the rules, once keventd has created it. With -c that is after the coldplug queue has drained. Fixes #503 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
3 files changed
+17
No files matched your search
@@ -163,6 +163,9 @@ All relevant changes are documented in this file.
|
||||
- Fix #512: `--` in the `command` of a block-format .conf, it was taken as the
|
||||
start of the description, so `command = "cmd -- arg"` ran `cmd` with
|
||||
description `arg`. Found by Alexandru Paniș
|
||||
- Fix #503: keventd did not touch its PID file after SIGHUP, so with a
|
||||
daemon-owned PID file Finit never saw it reassert readiness after a
|
||||
reload. Reported by Aaron Andersen
|
||||
- Fix a command whose name starts like a service option, e.g. `logger` or
|
||||
`pidof`. It was taken as the `log` or `pid` option and the next argument
|
||||
ran as the command, which also broke the `logger` example in finit.conf(5)
|
||||
|
||||
@@ -143,6 +143,7 @@ static int num_ac;
|
||||
static int level;
|
||||
static int logon;
|
||||
static int passive; /* power-supply only, no device management */
|
||||
static int ready; /* pidfile created, see issue #503 */
|
||||
|
||||
static struct rule_list rules = TAILQ_HEAD_INITIALIZER(rules);
|
||||
static char *rules_dir; /* extra rules dir from -r option */
|
||||
@@ -507,10 +508,13 @@ static void sigterm_cb(uev_t *w, void *arg, int events)
|
||||
uev_exit(w->ctx);
|
||||
}
|
||||
|
||||
/* Finit expects the pidfile touched to reassert readiness after SIGHUP */
|
||||
static void sighup_cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
(void)w; (void)arg; (void)events;
|
||||
kev_rules_reload();
|
||||
if (ready)
|
||||
pidfile(NULL);
|
||||
}
|
||||
|
||||
static void sigchld_cb(uev_t *w, void *arg, int events)
|
||||
@@ -613,6 +617,7 @@ static void coldplug_pidfile_cb(uev_t *w, void *arg, int events)
|
||||
return;
|
||||
|
||||
pidfile(NULL);
|
||||
ready = 1;
|
||||
logit(LOG_NOTICE, "keventd ready, coldplug queue drained");
|
||||
uev_timer_stop(w);
|
||||
}
|
||||
@@ -826,6 +831,7 @@ int main(int argc, char *argv[])
|
||||
logit(LOG_NOTICE, "keventd v%s started, draining coldplug queue...", KEVENTD_VERSION);
|
||||
} else {
|
||||
pidfile(NULL);
|
||||
ready = 1;
|
||||
logit(LOG_NOTICE, "keventd v%s started, waiting for events...", KEVENTD_VERSION);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,14 @@ run "ip link del probe0"
|
||||
sep "keventd readiness"
|
||||
retry 'assert_ready "keventd"' 50 0.2
|
||||
|
||||
# Finit does not touch a daemon-owned pidfile, so keventd must do it
|
||||
# after SIGHUP to reassert readiness, see issue #503. Signalled with
|
||||
# kill to keep Finit out of it.
|
||||
sep "keventd touches its pidfile on SIGHUP"
|
||||
run "touch -d '2000-01-01 00:00' /run/keventd.pid"
|
||||
run "kill -HUP $(texec cat /run/keventd.pid)"
|
||||
retry "test \$(texec stat -c %Y /run/keventd.pid) -gt 1000000000" 10 0.2
|
||||
|
||||
sep "interface add asserts <class/net/dummy0>"
|
||||
cat >> "$SYSROOT$FINIT_CONF" <<EOF
|
||||
service serv {
|
||||
|
||||
Reference in new issue
Block a user