From 682e80fed54805a6c7c54fbbc68b383f7904b339 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 30 Sep 2018 11:28:27 +0200 Subject: [PATCH] Remove HOOK_SVC_LOST, recommend using accounting instead Signed-off-by: Joachim Nilsson --- configure.ac | 1 - docs/build.md | 2 -- docs/plugins.md | 11 --------- plugins/Makefile.am | 8 ------ plugins/lost.c | 60 --------------------------------------------- src/plugin.c | 2 +- src/plugin.h | 2 -- src/service.c | 2 -- 8 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 plugins/lost.c diff --git a/configure.ac b/configure.ac index be6b960d..c2a1864a 100644 --- a/configure.ac +++ b/configure.ac @@ -95,7 +95,6 @@ AC_PLUGIN([inetd-chargen], [no], [Inetd plugin: character generator, RFC864]) AC_PLUGIN([inetd-daytime], [no], [Inetd plugin: daytime server, RFC867]) AC_PLUGIN([inetd-discard], [no], [Inetd plugin: discard server, RFC863]) AC_PLUGIN([inetd-time], [no], [Inetd plugin: time (rdate) server, RFC868]) -AC_PLUGIN([lost], [no], [Example HOOK_SVC_LOST plugin, very noisy as-is!]) AC_PLUGIN([resolvconf], [no], [Setup necessary files for resolvconf]) AC_PLUGIN([x11-common], [no], [Console setup (for X)]) AC_PLUGIN([netlink], [yes], [Basic netlink plugin for IFUP/IFDN and GW events. Can be replaced with externally built plugin that links with libnl or similar.]) diff --git a/docs/build.md b/docs/build.md index dd193635..e6b6becf 100644 --- a/docs/build.md +++ b/docs/build.md @@ -53,8 +53,6 @@ Below are a few of the main switches to configure: * `--enable-dbus-plugin`: Enable the optional D-Bus `dbus.so` plugin. -* `--enable-lost-plugin`: Enable noisy example plugin for `HOOK_SVC_LOST`. - * `--enable-resolvconf-plugin`: Enable the `resolvconf.so` optional plugin. * `--enable-x11-common-plugin`: Enable the optional X Window `x11-common.so` plugin. diff --git a/docs/plugins.md b/docs/plugins.md index ef4937d5..8c2d8eb8 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -47,9 +47,6 @@ For your convenience a set of *optional* plugins are available: * *initctl.so*: Extends finit with a traditional `initctl` functionality. -* *lost.so*: Very simple `HOOK_SVC_LOST` example. Logs process ID and - name to syslog. _Optional plugin._ - * *netlink.so*: Listens to Linux kernel Netlink events for gateway and interfaces. These events are then sent to the Finit service monitor for services that may want to be SIGHUP'ed on new default route or @@ -102,14 +99,6 @@ Hooks all modified/removed services have been stopped. When the hook has completed, Finit continues to start all modified and new services. -* `HOOK_SVC_LOST`: Called when a process is lost. When reconfiguring - services at runtime this hook may be called a lot. However, it may be - a quite useful hook to monitor a system post bootstrap when no, or - few, services are expected to exit. A default plugin `lost.so` is - available in the `plugins/` subdirectory as an example. - - **NOTE:** This hook callback gets the lost PID as argument. - * `HOOK_RUNLEVEL_CHANGE`: Called when the user has issued a runlevel change. The hook is called when services not matching the new runlevel have been been stopped. When the hook has completed, Finit diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 752beab3..17a67cae 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -39,10 +39,6 @@ libplug_la_SOURCES += time.c endif endif -if BUILD_LOST_PLUGIN -libplug_la_SOURCES += lost.c -endif - if BUILD_NETLINK_PLUGIN libplug_la_SOURCES += netlink.c endif @@ -84,10 +80,6 @@ pkglib_LTLIBRARIES += time.la endif endif -if BUILD_LOST_PLUGIN -pkglib_LTLIBRARIES += lost.la -endif - if BUILD_NETLINK_PLUGIN pkglib_LTLIBRARIES += netlink.la endif diff --git a/plugins/lost.c b/plugins/lost.c deleted file mode 100644 index 83970dc5..00000000 --- a/plugins/lost.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Example HOOK_SVC_LOST plugin, very noisy do not use as-is! - * - * Copyright (c) 2016 Joachim Nilsson - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "finit.h" -#include "svc.h" -#include "plugin.h" - -static void lost_pid(void *arg) -{ - pid_t pid = (uintptr_t)arg; - svc_t *svc; - - svc = svc_find_by_pid(pid); - if (!svc) - return; - - logit(LOG_INFO, "Lost PID %u, svc %s", pid, svc->cmd); -} - -static plugin_t plugin = { - .name = __FILE__, - .hook[HOOK_SVC_LOST] = { .cb = lost_pid }, -}; - -PLUGIN_INIT(plugin_init) -{ - plugin_register(&plugin); -} - -PLUGIN_EXIT(plugin_exit) -{ - plugin_unregister(&plugin); -} - -/** - * Local Variables: - * indent-tabs-mode: t - * c-file-style: "linux" - * End: - */ diff --git a/src/plugin.c b/src/plugin.c index f5b854ad..510b0599 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -189,7 +189,7 @@ int plugin_exists(hook_point_t no) return 0; } -/* Some hooks are called with a fixed argument, like HOOK_SVC_LOST */ +/* Some hooks are called with a fixed argument */ void plugin_run_hook(hook_point_t no, void *arg) { plugin_t *p, *tmp; diff --git a/src/plugin.h b/src/plugin.h index 0bc183db..18bd6e2c 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -56,7 +56,6 @@ * according to the following scheme: * * - HOOK_SVC_RECONF :: action/svc/reconf - * - HOOK_SVC_LOST :: action/svc/lost * - HOOK_RUNLEVEL_CHANGE :: action/sys/runlevel * * However, the implementation did not turn out to be stable enough for @@ -75,7 +74,6 @@ \ /* Runtime hooks, runlevel [S1-9] */ \ CHOOSE(HOOK_SVC_RECONF, "nop"), \ - CHOOSE(HOOK_SVC_LOST, "nop"), \ CHOOSE(HOOK_RUNLEVEL_CHANGE, "nop"), \ \ /* Shutdown hooks, runlevel [06] */ \ diff --git a/src/service.c b/src/service.c index 77ec57be..813ae218 100644 --- a/src/service.c +++ b/src/service.c @@ -922,8 +922,6 @@ void service_monitor(pid_t lost) if (tty_respawn(lost)) return; - plugin_run_hook(HOOK_SVC_LOST, (void *)(uintptr_t)lost); - svc = svc_find_by_pid(lost); if (!svc) { _d("collected unknown PID %d", lost);