mirror of
https://github.com/troglobit/finit.git
synced 2026-11-27 20:48:24 +00:00
Add support for calling initctl with process name as well as JOBID
This patch makes it possible to communicate process name or JOB[:ID] from initctl to Finit. When the process name translates into a service with multiple instances Finit applies the requested command to all instances. For example, two Dropbear SSH services running on two different ports, calling `initctl stop dropbear` stops both services. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
5d2172eac8
commit
577622c945
7 files changed
+166
-107
No files matched your search
@@ -24,7 +24,6 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/wait.h>
|
||||
#include <utmp.h>
|
||||
#include <net/if.h>
|
||||
#include "libite/lite.h"
|
||||
|
||||
@@ -38,10 +37,9 @@
|
||||
|
||||
#define RESPAWN_MAX 10 /* Prevent endless respawn of faulty services. */
|
||||
|
||||
static int is_norespawn (void);
|
||||
static int is_norespawn (void);
|
||||
static void restart_lost_procs (void);
|
||||
static void svc_dance (svc_t *svc);
|
||||
static void utmp_save (int pre, int now);
|
||||
static svc_t *find_inetd_svc (char *path, char *service, char *proto);
|
||||
|
||||
|
||||
@@ -433,7 +431,7 @@ void service_runlevel(int newlevel)
|
||||
runlevel = newlevel;
|
||||
|
||||
_d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel);
|
||||
utmp_save(prevlevel, newlevel);
|
||||
runlevel_set(prevlevel, newlevel);
|
||||
|
||||
/* Make sure to reload all *.conf in /etc/finit.d/ */
|
||||
svc_mark_dynamic();
|
||||
@@ -817,25 +815,6 @@ static void svc_dance(svc_t *svc)
|
||||
}
|
||||
}
|
||||
|
||||
static int encode(int lvl)
|
||||
{
|
||||
if (!lvl) return 0;
|
||||
return lvl + '0';
|
||||
}
|
||||
|
||||
static void utmp_save(int pre, int now)
|
||||
{
|
||||
struct utmp utent;
|
||||
|
||||
utent.ut_type = RUN_LVL;
|
||||
utent.ut_pid = (encode(pre) << 8) | (encode(now) & 0xFF);
|
||||
strlcpy(utent.ut_user, "runlevel", sizeof(utent.ut_user));
|
||||
|
||||
setutent();
|
||||
pututline(&utent);
|
||||
endutent();
|
||||
}
|
||||
|
||||
#ifndef INETD_DISABLED
|
||||
static svc_t *find_inetd_svc(char *path, char *service, char *proto)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user