mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00:00
Fix I/O plugin watcher, load plugins earlier to enable a new early hook!
Restructure start by calling the plugin loader earlier. This makes it
possible to run hooks even earlier. This also adds a new hook:
HOOK_ROOTFS_UP which runs as soon as the system root (/) is available.
Another very notable change is the slow refactor of helpers.c into a finit
helper library called libite.so (-lite). This is a light-weight
Also, lots of misc. fixes all over the place. Signal handling still really
needs to be looked into once more!
Makefile:
Add dependency handling for parallell build
Add libite library
ChangeLog:
Update with new 1.4 release. There is a lot of fixes!
libite/:
Collection of utility functions and C library extensions for
finit & its plugins
reboot.c:
New reboot tool. Simply sends SIGINT to PID 1
finit.h:
Cleanup old LISTEN_INITCTL define, code is in an optional plugin now
finit.c:
Let mdev/udev run *after* cls()
Add useful debug statement for /proc/cmdline
Earlier plugin load => new early hook point
Show OK/FAIL for total plugin load, not for each plugin => speedup
helpers.h:
Rename syslog macros to prevent common name clashes (DEBUG/ERROR)
Add __FILE__ to _e(), _d() and _pe() macros
helpers.c:
In ifconfig() the addr and mask arguments are now optional
The copyfile() has been moved to libite.so
Temporarily remove const directive from some functions to build
Use DFLSIG() macro in run_getty() to simplify code
plugin.h:
Add new HOOK_ROOTFS_UP hook
plugin.c:
Fix init_plugins() to actually register the plugin's I/O fd
Skip verbose listing of all plugins in plugin_load_all()
svc.c:
svc_start(): Dito
plugins/Makefile:
Inherit CFLAGS and LDFLAGS, but make sure to filter out -rdynamic
from LDFLAGS, it's used by the daemon, only
plugins/initctl.c:
New includes after helpers.h refactor
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
c002b5301f
commit
65c9e7ebc6
22 files changed
+1324
-111
No files matched your search
@@ -29,6 +29,7 @@
|
||||
#include "helpers.h"
|
||||
#include "private.h"
|
||||
#include "sig.h"
|
||||
#include "lite.h"
|
||||
#include "svc.h"
|
||||
|
||||
/* The registered services are kept in shared memory for easy read-only access
|
||||
@@ -269,6 +270,7 @@ int svc_start(svc_t *svc)
|
||||
{
|
||||
int respawn = svc->pid != 0;
|
||||
pid_t pid;
|
||||
sigset_t nmask, omask;
|
||||
char *args[MAX_NUM_SVC_ARGS];
|
||||
|
||||
/* Ignore if finit is SIGSTOP'ed */
|
||||
@@ -278,12 +280,22 @@ int svc_start(svc_t *svc)
|
||||
if (!respawn)
|
||||
print_desc("Starting ", svc->desc);
|
||||
|
||||
/* Block sigchild while forking. */
|
||||
sigemptyset(&nmask);
|
||||
sigaddset(&nmask, SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, &nmask, &omask);
|
||||
|
||||
pid = fork();
|
||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
if (pid == 0) {
|
||||
int i = 0;
|
||||
int uid = getuser(svc->username);
|
||||
struct sigaction sa;
|
||||
|
||||
sigemptyset(&nmask);
|
||||
sigaddset(&nmask, SIGCHLD);
|
||||
sigprocmask(SIG_UNBLOCK, &nmask, NULL);
|
||||
|
||||
/* Reset signal handlers that were set by the parent process */
|
||||
for (i = 1; i < NSIG; i++)
|
||||
DFLSIG(sa, i, 0);
|
||||
@@ -298,16 +310,23 @@ int svc_start(svc_t *svc)
|
||||
args[i] = NULL;
|
||||
|
||||
if (debug) {
|
||||
int fd = open (CONSOLE, O_WRONLY | O_APPEND);
|
||||
int fd;
|
||||
char buf[256] = "";
|
||||
|
||||
fd = open (CONSOLE, O_WRONLY | O_APPEND);
|
||||
if (-1 != fd) {
|
||||
dup2(STDOUT_FILENO, fd);
|
||||
dup2(STDERR_FILENO, fd);
|
||||
}
|
||||
|
||||
_e("%starting %s ", respawn ? "Res" : "S", svc->cmd);
|
||||
for (i = 0; args[i] && i < MAX_NUM_SVC_ARGS; i++)
|
||||
_e("%s ", args[i]);
|
||||
_e("");
|
||||
for (i = 0; args[i] && i < MAX_NUM_SVC_ARGS; i++) {
|
||||
char arg[MAX_ARG_LEN];
|
||||
|
||||
snprintf(arg, sizeof(arg), "%s ", args[i]);
|
||||
if ((sizeof(buf) - strlen(buf)) < strlen(arg))
|
||||
strcat(buf, arg);
|
||||
}
|
||||
_e("%starting %s: %s", respawn ? "Res" : "S", svc->cmd, buf);
|
||||
}
|
||||
|
||||
execvp(svc->cmd, args);
|
||||
@@ -383,9 +402,9 @@ void svc_start_all(void)
|
||||
|
||||
for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) {
|
||||
cmd = svc_enabled(svc, 0, NULL);
|
||||
if (cmd == SVC_START || (cmd == SVC_RELOAD && svc->pid == 0))
|
||||
if (SVC_START == cmd || (SVC_RELOAD == cmd && svc->pid == 0))
|
||||
svc_start(svc);
|
||||
else if (cmd == SVC_RELOAD)
|
||||
else if (SVC_RELOAD == cmd)
|
||||
svc_reload(svc);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user