From bb8a9c087d20ee6454e2b6bf4713ec0ce9db94f3 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 25 Aug 2013 21:27:50 -0500 Subject: start-stop-daemon: fix --quiet switch The --quiet switch wasn't really quiet, because we changed it to report errors. I am changing it back due to discussions on the listed bugs. X-Gentoo-Bug: 482396 X-Gentoo-Bug: 439174 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=439174 --- src/rc/_usage.h | 2 +- src/rc/start-stop-daemon.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/rc/_usage.h b/src/rc/_usage.h index 0882c22f..84b66b96 100644 --- a/src/rc/_usage.h +++ b/src/rc/_usage.h @@ -38,7 +38,7 @@ "Disable color output", \ "Display software version", \ "Run verbosely", \ - "Run quietly (Does not affect errors)" + "Run quietly" #define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1); #define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS); diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 5576d49d..4b9fcdd0 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -417,7 +417,7 @@ run_stop_schedule(const char *exec, const char *const *argv, } if (pidfile) { - pid = get_pid(pidfile, false); + pid = get_pid(pidfile, quiet); if (pid == -1) return 0; } @@ -436,6 +436,7 @@ run_stop_schedule(const char *exec, const char *const *argv, if (tkilled == 0) { if (progressed) printf("\n"); + if (! quiet) eerror("%s: no matching processes found", applet); } return tkilled; @@ -506,10 +507,12 @@ run_stop_schedule(const char *exec, const char *const *argv, if (progressed) printf("\n"); - if (nrunning == 1) - eerror("%s: %d process refused to stop", applet, nrunning); - else - eerror("%s: %d process(es) refused to stop", applet, nrunning); + if (! quiet) { + if (nrunning == 1) + eerror("%s: %d process refused to stop", applet, nrunning); + else + eerror("%s: %d process(es) refused to stop", applet, nrunning); + } return -nrunning; } @@ -1289,7 +1292,7 @@ start_stop_daemon(int argc, char **argv) /* We don't redirect stdin as some daemons may need it */ if (background || quiet || redirect_stdout) dup2(stdout_fd, STDOUT_FILENO); - if (background || redirect_stderr) + if (background || quiet || redirect_stderr) dup2(stderr_fd, STDERR_FILENO); for (i = getdtablesize() - 1; i >= 3; --i) @@ -1320,9 +1323,11 @@ start_stop_daemon(int argc, char **argv) return -1; } } while (!WIFEXITED(i) && !WIFSIGNALED(i)); - if (!WIFEXITED(i) || WEXITSTATUS(i) != 0) - eerrorx("%s: failed to start `%s'", applet, exec); - + if (!WIFEXITED(i) || WEXITSTATUS(i) != 0) { + if (!quiet) + eerrorx("%s: failed to start `%s'", applet, exec); + exit(EXIT_FAILURE); + } pid = spid; } @@ -1356,7 +1361,7 @@ start_stop_daemon(int argc, char **argv) alive = true; } else { if (pidfile) { - pid = get_pid(pidfile, false); + pid = get_pid(pidfile, true); if (pid == -1) { eerrorx("%s: did not " "create a valid" -- cgit v1.2.3