diff --git a/plugins/pidfile.c b/plugins/pidfile.c index dfb3b7df..fbd525c0 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -84,6 +84,9 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask) mkcond(svc, cond, sizeof(cond)); if (mask & (IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) { svc_started(svc); + if (!svc_has_pidfile(svc)) + pid_file_set(svc, fn, 1); + if (svc_is_forking(svc)) { pid_t pid; diff --git a/src/svc.c b/src/svc.c index 323243c4..e9e53ebb 100644 --- a/src/svc.c +++ b/src/svc.c @@ -416,7 +416,17 @@ svc_t *svc_find_by_pidfile(char *fn) pid = pid_file_read(fn); if (pid <= 0) { - _d("pid_file_read(%s) => %d", fn, pid); + for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) { + int v = 0; + + if (svc->pidfile[0] == '!') + v = 1; + if (strcmp(&svc->pidfile[v], fn)) + continue; + + return svc; + } + return NULL; }