mirror of
https://github.com/troglobit/finit.git
synced 2026-11-10 16:31:21 +00: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:
1 parent
b4ccc8b008
commit
1f88e1ff8a
3 files changed
+28
-6
No files matched your search
@@ -145,6 +145,7 @@ void conf_parse_events(svc_t *svc, char *events)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
svc->state = SVC_CONDHALT_STATE;
|
||||||
strlcpy(svc->events, ptr, sizeof(svc->events));
|
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)) {
|
if (svc_is_inetd(svc)) {
|
||||||
char *iface, *name = service;
|
char *iface, *name = service;
|
||||||
|
|
||||||
|
svc->state = SVC_WAITING_STATE;
|
||||||
if (svc->inetd.cmd && plugin)
|
if (svc->inetd.cmd && plugin)
|
||||||
name = plugin->name;
|
name = plugin->name;
|
||||||
|
|
||||||
|
|||||||
@@ -379,16 +379,36 @@ int svc_clean_bootstrap(svc_t *svc)
|
|||||||
|
|
||||||
char *svc_status(svc_t *svc)
|
char *svc_status(svc_t *svc)
|
||||||
{
|
{
|
||||||
if (svc->pid)
|
|
||||||
return "running";
|
|
||||||
|
|
||||||
if (!svc_in_runlevel(svc, runlevel))
|
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 "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 */
|
/* Same base service, return unique ID */
|
||||||
|
|||||||
Reference in new issue
Block a user