diff --git a/api.c b/api.c index 3d57b910..cca6812d 100644 --- a/api.c +++ b/api.c @@ -372,6 +372,11 @@ error: return 1; } +int api_exit(void) +{ + return shutdown(api_watcher.fd, SHUT_RDWR) || + close(api_watcher.fd); +} /** * Local Variables: diff --git a/finit.c b/finit.c index 11fcbfb0..be2b6f5f 100644 --- a/finit.c +++ b/finit.c @@ -231,13 +231,11 @@ int main(int argc, char* argv[]) #endif run_interactive(SETUP_DEVFS, "Populating device tree"); -#ifndef ENABLE_STATIC /* * Load plugins first, finit.conf may contain references to * features implemented by plugins. */ - plugin_load_all(&loop, PLUGIN_PATH); -#endif + plugin_init(&loop, PLUGIN_PATH); /* * Parse /etc/finit.conf, main configuration file diff --git a/plugin.c b/plugin.c index 907c4d07..d755f8f1 100644 --- a/plugin.c +++ b/plugin.c @@ -298,7 +298,7 @@ static void check_plugin_depends(plugin_t *plugin) } #endif /* ENABLE_STATIC */ -int plugin_load_all(uev_ctx_t *ctx, char *path) +int plugin_init(uev_ctx_t *ctx, char *path) { int fail = 0; #ifndef ENABLE_STATIC @@ -343,6 +343,14 @@ exit: return fail; } +void plugin_exit(void) +{ + plugin_t *p, *tmp; + + PLUGIN_ITERATOR(p, tmp) + plugin_unregister(p); +} + /** * Local Variables: * indent-tabs-mode: t diff --git a/private.h b/private.h index a8e98733..f832861e 100644 --- a/private.h +++ b/private.h @@ -28,16 +28,23 @@ #include "svc.h" #include "plugin.h" -uev_ctx_t *ctx; /* Main loop context */ +/* + * Main loop context + */ +uev_ctx_t *ctx; int api_init (uev_ctx_t *ctx); +int api_exit (void); + int client (int argc, char *argv[]); void service_monitor (pid_t lost); void plugin_run_hook (hook_point_t no, void *arg); void plugin_run_hooks (hook_point_t no); -int plugin_load_all (uev_ctx_t *ctx, char *path); + +int plugin_init (uev_ctx_t *ctx, char *path); +void plugin_exit (void); #endif /* FINIT_PRIVATE_H_ */