aboutsummaryrefslogtreecommitdiff
path: root/initd/init.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-22 01:02:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-22 13:41:18 +0200
commit59731dd69bb4be66c721b3de66fb2ab80bec3e7e (patch)
treea5b17b8d95c1ffeb4b3312893be3bb9567b64363 /initd/init.h
parent720220a3c3c42b92734e2a92f9094348451e187b (diff)
Add helper program for running services
We no longer need to keep entire scripts in init program (i.e. saving space) and reduce the code and complexity of the init program. The runsvc tool can later be extended to do more complex child setup, such as configuring namespaces or seccomp without adding complexity or memory footprint to init. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'initd/init.h')
-rw-r--r--initd/init.h39
1 files changed, 8 insertions, 31 deletions
diff --git a/initd/init.h b/initd/init.h
index 3510073..d07f310 100644
--- a/initd/init.h
+++ b/initd/init.h
@@ -27,7 +27,7 @@
#include "telinit.h"
#include "util.h"
-#define ENVFILE ETCPATH "/initd.env"
+#define RUNSVCBIN SCRIPTDIR "/runsvc"
enum {
STATUS_OK = 0,
@@ -36,35 +36,20 @@ enum {
STATUS_STARTED,
};
-/********** runlst.c **********/
+/********** runsvc.c **********/
/*
- Plow through an array of strings and execute each one, i.e. do
- a fork() and exec().
+ Invoke the runsvc command to execute the comands of a service.
- In the parent process, wait() until the child is done before
- continuing through the list.
-
- If ctty is not NULL, open it and redirect all I/O of the child
- process to that file.
-
- If everyhing works, the function returns EXIT_SUCCESS. If one child
- does not exit with EXIT_SUCCESS, processing of the list is aborted
- and the function returns the exit status of the failed process.
+ Returns the pid of the child process containing the runsvc instance.
*/
-int runlst_wait(exec_t *list, const char *ctty);
+pid_t runsvc(service_t *svc);
/*
- Does basically the same as runlst_wait, but asynchronously.
-
- A child process is created that calls runlst_wait exits with the
- result of runlst_wait. In the parent process, the function returns
- immediately with the PID of the child process.
-
- Alternatively, if num is 1, the child process directly exec()s the
- given command.
+ Start a service using runsvc, but wait until the child process
+ terminats and return its exit status.
*/
-pid_t runlst(exec_t *list, const char *ctty);
+int runsvc_wait(service_t *svc);
/********** status.c **********/
@@ -111,14 +96,6 @@ void svclist_add(service_t *svc);
*/
service_t *svclist_remove(pid_t pid);
-/********** env.c **********/
-
-/*
- Read /etc/initd.env (actually ENVFILE defined above)
- and setup environment variables for init.
-*/
-int initenv(void);
-
/********** signal_<platform>.c **********/
/*