mirror of
https://github.com/troglobit/finit.git
synced 2026-10-16 10:39:35 +00:00
plugins: pidfile: track PID file in svc, if svc has none declared
Services that create their own PID files usually don't declare one with Finit. This patch adds support to track those PID files anywayt at runtime for the purpose of identifying match svc_t when a PID file is removed, i.e. when a service exits. - On IN_CREATE the pidfile.so plugin saves the pid file name in svc_t - On ON_DELETE the pidfile.so plugin finds svc_t based on pid file Quicker tracking and less dead code, win-win. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
5c4146cfe4
commit
280608f30e
2 files changed
+14
-1
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user