mirror of
https://github.com/troglobit/finit.git
synced 2026-10-17 10:49:34 +00:00
Drop confusing leading / in sig2str() and code2str()
This was added for the benefit of `initctl status foo`, but we have other users of these functions that don't expect a leading slash. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
4709394ae6
commit
bd5cf7c9eb
2 files changed
+12
-12
No files matched your search
+10
-4
@@ -738,15 +738,21 @@ static char *svc_environ(svc_t *svc, char *buf, size_t len)
|
||||
static char *exit_status(svc_t *svc, char *buf, size_t len)
|
||||
{
|
||||
int rc, sig;
|
||||
char *str;
|
||||
|
||||
rc = WEXITSTATUS(svc->status);
|
||||
sig = WTERMSIG(svc->status);
|
||||
|
||||
if (WIFEXITED(svc->status))
|
||||
snprintf(buf, len, " (code=exited, status=%d%s%s)", rc, code2str(rc),
|
||||
if (WIFEXITED(svc->status)) {
|
||||
str = code2str(rc);
|
||||
snprintf(buf, len, " (code=exited, status=%d%s%s%s)", rc,
|
||||
str[0] ? "/" : "", str,
|
||||
svc->manual ? ", manual=yes" : "");
|
||||
else if (WIFSIGNALED(svc->status))
|
||||
snprintf(buf, len, " (code=signal, status=%d%s)", sig, sig2str(sig));
|
||||
}
|
||||
else if (WIFSIGNALED(svc->status)) {
|
||||
str = sig2str(sig);
|
||||
snprintf(buf, len, " (code=signal, status=%d%s%s)", sig, str[0] ? "/" : "", str);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
+2
-8
@@ -304,13 +304,10 @@ int strtobytes(char *arg)
|
||||
|
||||
char *sig2str(int signo)
|
||||
{
|
||||
static char signame[8];
|
||||
|
||||
if (signo < 1 || signo >= (int)NELEMS(signames))
|
||||
return "";
|
||||
|
||||
snprintf(signame, sizeof(signame), "/%s", signames[signo]);
|
||||
return signame;
|
||||
return signames[signo];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,13 +334,10 @@ int str2sig(char *sig)
|
||||
|
||||
char *code2str(int code)
|
||||
{
|
||||
static char codename[20];
|
||||
|
||||
if (code < 0 || code >= (int)NELEMS(exitcodes))
|
||||
return "";
|
||||
|
||||
snprintf(codename, sizeof(codename), "/%s", exitcodes[code]);
|
||||
return codename;
|
||||
return exitcodes[code];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user