mirror of
https://github.com/troglobit/finit.git
synced 2026-10-10 16:52:39 +07:00
Refactor svc_status() used by 'initctl show'
Leverage new svc_t states in initctl status/show output. Also, ensure different svc_t types have correct start state. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -145,6 +145,7 @@ void conf_parse_events(svc_t *svc, char *events)
|
||||
return;
|
||||
}
|
||||
|
||||
svc->state = SVC_CONDHALT_STATE;
|
||||
strlcpy(svc->events, ptr, sizeof(svc->events));
|
||||
}
|
||||
|
||||
|
||||
@@ -804,6 +804,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
|
||||
if (svc_is_inetd(svc)) {
|
||||
char *iface, *name = service;
|
||||
|
||||
svc->state = SVC_WAITING_STATE;
|
||||
if (svc->inetd.cmd && plugin)
|
||||
name = plugin->name;
|
||||
|
||||
|
||||
@@ -379,16 +379,36 @@ int svc_clean_bootstrap(svc_t *svc)
|
||||
|
||||
char *svc_status(svc_t *svc)
|
||||
{
|
||||
if (svc->pid)
|
||||
return "running";
|
||||
|
||||
if (!svc_in_runlevel(svc, runlevel))
|
||||
return "halted";
|
||||
return "stopped";
|
||||
|
||||
if (svc_is_inetd(svc))
|
||||
switch (svc->state) {
|
||||
case SVC_WAITING_STATE:
|
||||
return "waiting";
|
||||
|
||||
return "stopped";
|
||||
case SVC_PAUSED_STATE:
|
||||
return "paused";
|
||||
|
||||
case SVC_CONDHALT_STATE:
|
||||
return "nocond";
|
||||
|
||||
case SVC_RESTART_STATE:
|
||||
return "restart";
|
||||
|
||||
case SVC_RELOAD_STATE:
|
||||
return "reload";
|
||||
|
||||
case SVC_RUNNING_STATE:
|
||||
if (svc->pid)
|
||||
return "running";
|
||||
/* Fall through */
|
||||
|
||||
case SVC_HALTED_STATE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "halted";
|
||||
}
|
||||
|
||||
/* Same base service, return unique ID */
|
||||
|
||||
Reference in New Issue
Block a user