From 0d4bc6958468abf61a2e0b97a037e8ca9a1e9d29 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 11 Jan 2018 10:50:19 +0100 Subject: [PATCH] pidfile: Use new svc_find_by_pidfile() in plugin A service may now have a custom PID file, possibly because it doesn't really create one itself. This needs to be taken into account also in the pidfile plugin. Signed-off-by: Joachim Nilsson --- plugins/pidfile.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index 2491d1f1..8b48275d 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -50,7 +50,6 @@ static void pidfile_callback(void *arg, int fd, int events) struct inotify_event *ev; ssize_t sz, len; - char *basename; svc_t *svc; sz = read(fd, ev_buf, sizeof(ev_buf) - 1); @@ -60,23 +59,19 @@ static void pidfile_callback(void *arg, int fd, int events) } ev_buf[sz] = 0; - for (ev = (void *)ev_buf; sz > (ssize_t)sizeof(*ev); + for (ev = (void *)ev_buf; + sz > (ssize_t)sizeof(*ev); len = sizeof(*ev) + ev->len, ev = (void *)ev + len, sz -= len) { - /* ev = (void *)(ev + 1) + ev->len, sz -= sizeof(*ev) + ev->len) { */ if (!ev->mask || !strstr(ev->name, ".pid")) continue; - basename = strtok(ev->name, "."); - if (!basename) - continue; - - svc = svc_find_by_nameid(basename, 1); + svc = svc_find_by_pidfile(ev->name); if (!svc) continue; /* TODO FIXME XXX WKZ check that pid is controlled by finit */ - _d("%s: match %s", basename, svc->cmd); + _d("%s: match %s", ev->name, svc->cmd); mkcond(cond, sizeof(cond), svc->cmd); if (ev->mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY)) { svc_started(svc);