mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
New function, svc_find_by_pidfile()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "finit.h"
|
||||
#include "svc.h"
|
||||
#include "helpers.h"
|
||||
#include "pid.h"
|
||||
#include "util.h"
|
||||
|
||||
/* Each svc_t needs a unique job# */
|
||||
@@ -342,6 +343,25 @@ svc_t *svc_find_by_nameid(char *name, int id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* svc_find_by_plidfile - Find an service object by its PID file
|
||||
* @fn: PID file, can be absolute path or relative to /run
|
||||
*
|
||||
* Returns:
|
||||
* A pointer to an &svc_t object, or %NULL if not found.
|
||||
*/
|
||||
svc_t *svc_find_by_pidfile(char *fn)
|
||||
{
|
||||
svc_t *svc, *iter = NULL;
|
||||
|
||||
for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) {
|
||||
if (string_compare(fn, pid_file(svc)))
|
||||
return svc;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* svc_mark_dynamic - Mark dynamically loaded services for deletion.
|
||||
*
|
||||
|
||||
@@ -137,6 +137,7 @@ svc_t *svc_find (char *cmd, int id);
|
||||
svc_t *svc_find_by_pid (pid_t pid);
|
||||
svc_t *svc_find_by_jobid (int job, int id);
|
||||
svc_t *svc_find_by_nameid (char *name, int id);
|
||||
svc_t *svc_find_by_pidfile (char *fn);
|
||||
|
||||
svc_t *svc_iterator (svc_t **iter, int first);
|
||||
svc_t *svc_inetd_iterator (svc_t **iter, int first);
|
||||
|
||||
Reference in New Issue
Block a user