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:
Joachim Wiberg committed 2026-11-17 06:21:26 +01:00
1 parent bf42811a13
commit 14fd315f38
3 files changed
+17

No files matched your search

+6
View File
@@ -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);
}