diff --git a/finit.c b/finit.c index 6d3aea04..026a397e 100644 --- a/finit.c +++ b/finit.c @@ -43,9 +43,9 @@ int debug = 0; int quiet = KERNEL_QUIET; /* Delayed disable of verbose mode. */ int verbose = VERBOSE_MODE; -int runlevel = 0; /* Bootstrap */ +int runlevel = 0; /* Bootstrap 'S' */ int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */ -int prevlevel = 0; /* HALT */ +int prevlevel = -1; char *sdown = NULL; char *network = NULL; char *username = NULL; diff --git a/service.c b/service.c index ea5738da..74d77b74 100644 --- a/service.c +++ b/service.c @@ -598,7 +598,8 @@ void service_runlevel(int newlevel) else erase("/etc/nologin"); - if (0 != prevlevel) + /* No TTYs run at bootstrap, they have a delayed start. */ + if (prevlevel > 0) tty_runlevel(runlevel); } @@ -869,6 +870,9 @@ void service_monitor(pid_t lost) if (lost != svc->pid) continue; + if (!prevlevel && svc_clean_bootstrap(svc)) + continue; + if (SVC_TYPE_SERVICE != svc->type) { svc->pid = 0; continue; diff --git a/svc.c b/svc.c index 0bfddbc8..5b4ae777 100644 --- a/svc.c +++ b/svc.c @@ -359,6 +359,24 @@ void svc_clean_dynamic(void (*cb)(svc_t *)) } } +/** + * svc_clean_bootstrap - Remove bootstrap-only services after boot + * @svc: Pointer to &svc_t object + * + * Returns: + * %TRUE(1) if object was bootstrap-only, otherwise %FALSE(0) + */ +int svc_clean_bootstrap(svc_t *svc) +{ + if (!ISOTHER(svc->runlevels, 0)) { + svc->pid = 0; + svc_del(svc); + return 1; + } + + return 0; +} + char *svc_status(svc_t *svc) { if (svc->pid) diff --git a/svc.h b/svc.h index 1a6ed49f..ab70f4bf 100644 --- a/svc.h +++ b/svc.h @@ -144,6 +144,7 @@ void svc_foreach_dynamic (void (*cb)(svc_t *)); void svc_mark_dynamic (void); void svc_check_dirty (svc_t *svc, time_t mtime); void svc_clean_dynamic (void (*cb)(svc_t *)); +int svc_clean_bootstrap (svc_t *svc); char *svc_status (svc_t *svc); int svc_next_id (char *cmd);