commit 0b64abc255856e18253ba65068242ee2e55bf9be
parent ae3a4d23b9c6c6bd19e9ea11a1ae592d16fb7dcf
Author: Gerrit Pape <pape@smarden.org>
Date: Fri, 1 Aug 2014 08:34:38 +0000
* sv.c: properly format status command's output on failure cases.
Diffstat:
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/package/CHANGES b/package/CHANGES
@@ -1,5 +1,6 @@
2.1.2
+ * sv.c: properly format status command's output on failure cases.
* sv.c: support optional LSB init script actions reload and
try-restart.
* man/sv.8: "sv exit" does not send a TERM signal to the log service
diff --git a/src/sv.c b/src/sv.c
@@ -41,6 +41,7 @@ unsigned int lsb;
unsigned int verbose =0;
unsigned long wait =7;
unsigned int kll =0;
+unsigned int islog =0;
struct taia tstart, tnow, tdiff;
struct tai tstatus;
@@ -67,6 +68,7 @@ void fatal2(char *m1, char *m2) {
void out(char *p, char *m1) {
buffer_puts(buffer_1, p);
buffer_puts(buffer_1, *service);
+ if (islog) buffer_puts(buffer_1, "/log");
buffer_puts(buffer_1, ": ");
buffer_puts(buffer_1, m1);
if (errno) {
@@ -155,18 +157,20 @@ int status(char *unused) {
rc =svstatus_get();
switch(rc) { case -1: if (lsb) done(4); case 0: return(0); }
rc =svstatus_print(*service);
+ islog =1;
if (chdir("log") == -1) {
if (errno != error_noent) {
- outs("; log: "); outs(WARN);
- outs("unable to change to log service directory: ");
- outs(error_str(errno));
+ outs("; ");
+ warn("unable to change directory");
}
+ else outs("\n");
}
- else
- if (svstatus_get()) {
- outs("; "); svstatus_print("log");
- }
- flush("\n");
+ else {
+ outs("; ");
+ if (svstatus_get()) { rc =svstatus_print("log"); outs("\n"); }
+ }
+ islog =0;
+ flush("");
if (lsb) switch(rc) { case 1: done(0); case 2: done(3); case 0: done(4); }
return(rc);
}
diff --git a/src/sv.dist b/src/sv.dist
@@ -1,7 +1,7 @@
usage: sv [-v] [-w sec] command service ...
100
-$Id: 7d3ba19cde56692911cf4b2d711774583b1b860f $
+$Id: 900314260c6d52c986c5357673bea2f3bd3f4698 $
usage: sv [-v] [-w sec] command service ...
100