mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
Convert finit to use libev and fix so plugin ctors runs on dlopen().
Lots of cleanup and simplification of the main code in this commit. Most notably libev has been added to take care of the main loop and monitor services. Still TODO is migrating to use the libev signal handling. Convert initctl.c:listen_initctl() to a plugin instead. This also meant introducing a new form of I/O plugin to finit, also handled by libev. Load plugins *after* we've setup the base filesystem (BASEFS) in case plugins reside on a filesystem not reachable before "mount -a" has run. This also has the side effect of lining up nicely with the first level plugin hooks. If a plugin wants to hook up with a loded service we connect them by their respective numeric IDs in plugin_register(). I.e., the service monitor checks if a service has a registered callback, which in turn decides if a service should be started, stopped or reloaded. Rip out old EeePC distribution defines from finit.h, none of it really applies anymore. If you need distribution specific settings this is the place to put them. Make hookpoint names (#defines) clearer: after BASEFS, after networking, after all setup, etc. Use #inlude_next <signal.h> in signal.h to include system header file! Simplify service monitor: move essential code to svc.c and rip out the TIPC dependency. Write your own service.so plugin, or wait for a more complete example of how to extend service monitoring using the primitives in svc.c Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
5dda9051ac
commit
0e02429e75
25 files changed
+620
-1073
No files matched your search
@@ -40,10 +40,12 @@
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "finit.h"
|
||||
#include "helpers.h"
|
||||
#include "plugin.h"
|
||||
#include "private.h"
|
||||
#include "signal.h"
|
||||
|
||||
static int stopped = 0;
|
||||
@@ -85,8 +87,8 @@ void do_shutdown (int sig)
|
||||
*/
|
||||
static void shutdown_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
|
||||
{
|
||||
_d("Rebooting on signal %d from %s (PID %d) with code %d",
|
||||
sig, get_pidname(info->si_pid, NULL, 0), info->si_pid, info->si_code);
|
||||
_d("Rebooting on signal %d from %s (PID %d)",
|
||||
sig, get_pidname(info->si_pid, NULL, 0), info->si_pid);
|
||||
|
||||
do_shutdown(sig);
|
||||
}
|
||||
@@ -94,12 +96,11 @@ static void shutdown_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
|
||||
/*
|
||||
* SIGCHLD: one of our children has died
|
||||
*/
|
||||
static void chld_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
|
||||
static void chld_handler(int UNUSED(sig), siginfo_t *UNUSED(info), void *UNUSED(ctx))
|
||||
{
|
||||
int status;
|
||||
|
||||
_d("Child %s died, harvesting. Signal %d from pid %d code %d",
|
||||
get_pidname(info->si_pid, NULL, 0), sig, info->si_pid, info->si_code);
|
||||
// _d("Child %d died due to signal %d, harvesting.", info->si_pid, sig);
|
||||
while (waitpid(-1, &status, WNOHANG) != 0) {
|
||||
if (errno == ECHILD)
|
||||
break;
|
||||
@@ -111,15 +112,15 @@ static void chld_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
|
||||
*/
|
||||
static void sigstop_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
|
||||
{
|
||||
_d("Received SIGSTOP(%d) from %s (PID %d) code %d",
|
||||
sig, get_pidname(info->si_pid, NULL, 0), info->si_pid, info->si_code);
|
||||
_d("Received SIGSTOP(%d) from %s (PID %d)",
|
||||
sig, get_pidname(info->si_pid, NULL, 0), info->si_pid);
|
||||
touch(SYNC_STOPPED);
|
||||
stopped ++;
|
||||
}
|
||||
static void sigcont_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
|
||||
{
|
||||
_d("Received SIGCONT(%d) from %s (PID %d) code %d",
|
||||
sig, get_pidname(info->si_pid, NULL, 0), info->si_pid, info->si_code);
|
||||
_d("Received SIGCONT(%d) from %s (PID %d)",
|
||||
sig, get_pidname(info->si_pid, NULL, 0), info->si_pid);
|
||||
stopped = 0;
|
||||
remove(SYNC_STOPPED);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user