mirror of
https://github.com/troglobit/finit.git
synced 2026-10-14 10:19:36 +00:00
Fix #274: allow manual:yes on sysv/service/run/task
Prior to this change only service stanzas respected the manual:yes
option, now it (should) work on any svc_t type. Not tested on ttys.
The initctl tool has been given an extra manual=yes output for these
types of run/task/service entries, shown only when the manual option
is set.
Example:
root@anarchy:~# initctl status foo.sh
Status : stopped (code=exited, status=0/SUCCESS, manual=yes)
Identity : foo.sh ~~~~~~~~~~~~
Description : Hej foo
Origin : /etc/finit.d/enabled/foo.conf
Environment :
Condition(s):
Command : /root/foo.sh
PID file : none
PID : 0
User : root
Group : root
Uptime : N/A
Starts : 1
Restarts : 0 (0/10)
Runlevels : [--2345----]
Notice also the new `Starts : 1` which is a counter for the number of
starts in the current runlevel. On runlevel change it is reset to 0.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
6de67ed107
commit
5f908cae49
3 files changed
+21
-12
No files matched your search
+12
-9
@@ -692,16 +692,17 @@ static char *svc_environ(svc_t *svc, char *buf, size_t len)
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char *exit_status(int status, char *buf, size_t len)
|
||||
static char *exit_status(svc_t *svc, char *buf, size_t len)
|
||||
{
|
||||
int rc, sig;
|
||||
|
||||
rc = WEXITSTATUS(status);
|
||||
sig = WTERMSIG(status);
|
||||
rc = WEXITSTATUS(svc->status);
|
||||
sig = WTERMSIG(svc->status);
|
||||
|
||||
if (WIFEXITED(status))
|
||||
snprintf(buf, len, " (code=exited, status=%d%s)", rc, code2str(rc));
|
||||
else if (WIFSIGNALED(status))
|
||||
if (WIFEXITED(svc->status))
|
||||
snprintf(buf, len, " (code=exited, status=%d%s%s)", rc, code2str(rc),
|
||||
svc->manual ? ", manual=yes" : "");
|
||||
else if (WIFSIGNALED(svc->status))
|
||||
snprintf(buf, len, " (code=signal, status=%d%s)", sig, sig2str(sig));
|
||||
|
||||
return buf;
|
||||
@@ -717,7 +718,7 @@ static char *status(svc_t *svc, int full)
|
||||
s = svc_status(svc);
|
||||
switch (svc->state) {
|
||||
case SVC_HALTED_STATE:
|
||||
exit_status(svc->status, ok, sizeof(ok));
|
||||
exit_status(svc, ok, sizeof(ok));
|
||||
color = "\e[1m";
|
||||
break;
|
||||
|
||||
@@ -726,7 +727,7 @@ static char *status(svc_t *svc, int full)
|
||||
break;
|
||||
|
||||
case SVC_DONE_STATE:
|
||||
exit_status(svc->status, ok, sizeof(ok));
|
||||
exit_status(svc, ok, sizeof(ok));
|
||||
if (WIFEXITED(svc->status)) {
|
||||
if (WEXITSTATUS(svc->status))
|
||||
color = "\e[1;31m";
|
||||
@@ -741,7 +742,7 @@ static char *status(svc_t *svc, int full)
|
||||
break;
|
||||
|
||||
default:
|
||||
exit_status(svc->status, ok, sizeof(ok));
|
||||
exit_status(svc, ok, sizeof(ok));
|
||||
color = "\e[1;33m";
|
||||
break;
|
||||
}
|
||||
@@ -831,6 +832,8 @@ static int show_status(char *arg)
|
||||
printf(" User : %s\n", svc->username);
|
||||
printf(" Group : %s\n", svc->group);
|
||||
printf(" Uptime : %s\n", svc->pid ? uptime(now - svc->start_time, uptm, sizeof(uptm)) : uptm);
|
||||
if (svc->manual)
|
||||
printf(" Starts : %d\n", svc->once);
|
||||
printf(" Restarts : %d (%d/%d)\n", svc->restart_tot, svc->restart_cnt, svc->restart_max);
|
||||
printf(" Runlevels : %s\n", runlevel_string(runlevel, svc->runlevels));
|
||||
if (cgrp && svc->pid > 1) {
|
||||
|
||||
Reference in new issue
Block a user