mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 08:24:43 +07:00
Clean up bootstrap-only tasks when leaving bootstrap 'S' runlevel
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user