diff --git a/src/finit.c b/src/finit.c index 2754ed41..77418acf 100644 --- a/src/finit.c +++ b/src/finit.c @@ -440,6 +440,9 @@ int main(int argc, char* argv[]) */ service_runlevel(cfglevel); + /* Clean up bootstrap-only tasks/services that never started */ + svc_prune_bootstrap(); + _d("Running svc up hooks ..."); plugin_run_hooks(HOOK_SVC_UP); diff --git a/src/svc.c b/src/svc.c index f771a3ed..a2566b70 100644 --- a/src/svc.c +++ b/src/svc.c @@ -486,6 +486,23 @@ int svc_clean_bootstrap(svc_t *svc) return 0; } +/** + * svc_prune_bootstrap - Prune any remaining bootstrap tasks + * + * This function cleans up all bootstrap tasks that have not yet been + * collected, or that never even ran in bootstrap. All other instances + * when svc_clean_bootstrap() is called are when a service is collected. + */ +void svc_prune_bootstrap(void) +{ + svc_t *svc; + + for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) { + if (!svc->pid) + svc_clean_bootstrap(svc); + } +} + char *svc_status(svc_t *svc) { switch (svc->state) { diff --git a/src/svc.h b/src/svc.h index dfe141e6..791a6ee9 100644 --- a/src/svc.h +++ b/src/svc.h @@ -166,6 +166,7 @@ void svc_mark_dirty (svc_t *svc); void svc_mark_clean (svc_t *svc); void svc_clean_dynamic (void (*cb)(svc_t *)); int svc_clean_bootstrap (svc_t *svc); +void svc_prune_bootstrap (void); char *svc_status (svc_t *svc); const char *svc_dirtystr (svc_t *svc);