From 8f415aeaf61a032946ab9aec19fd946abc67d54e Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 5 Apr 2016 03:45:23 +0200 Subject: [PATCH] Add HOOK_SVC_START to detect started processes This patch adds support for the runtime `HOOK_SVC_START`. Customer request. Signed-off-by: Joachim Nilsson --- README.md | 5 +++++ plugin.h | 1 + service.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 855629ad..db2ea5d7 100644 --- a/README.md +++ b/README.md @@ -538,6 +538,11 @@ state, etc. Available hook points are: **NOTE:** This hook callback gets the lost PID as argument. +* `HOOK_SVC_START`: Like `HOOK_SVC_LOST`, but called when a process is + started. Same caveats apply. + + **NOTE:** This hook callback gets the new 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/plugin.h b/plugin.h index bba5a438..0b8fca73 100644 --- a/plugin.h +++ b/plugin.h @@ -52,6 +52,7 @@ typedef enum { /* Runtime hooks */ HOOK_SVC_RECONF, HOOK_SVC_LOST, + HOOK_SVC_START, HOOK_RUNLEVEL_CHANGE, /* Shutdown hooks */ diff --git a/service.c b/service.c index efd85ffb..ef5b364e 100644 --- a/service.c +++ b/service.c @@ -248,6 +248,8 @@ static int service_start(svc_t *svc) close(svc->stdin); #endif + plugin_run_hook(HOOK_SVC_START, (void *)(uintptr_t)pid); + if (SVC_TYPE_RUN == svc->type) { result = WEXITSTATUS(complete(svc->cmd, pid)); svc->pid = 0;