Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/
Date: Mon, 26 Aug 2013 20:59:55
Message-Id: 1377550271.bb8a9c087d20ee6454e2b6bf4713ec0ce9db94f3.WilliamH@OpenRC
1 commit: bb8a9c087d20ee6454e2b6bf4713ec0ce9db94f3
2 Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
3 AuthorDate: Mon Aug 26 02:27:50 2013 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Mon Aug 26 20:51:11 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=bb8a9c08
7
8 start-stop-daemon: fix --quiet switch
9
10 The --quiet switch wasn't really quiet, because we changed it to report
11 errors. I am changing it back due to discussions on the listed bugs.
12
13 X-Gentoo-Bug: 482396
14 X-Gentoo-Bug: 439174
15 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
16 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=439174
17
18 ---
19 src/rc/_usage.h | 2 +-
20 src/rc/start-stop-daemon.c | 25 +++++++++++++++----------
21 2 files changed, 16 insertions(+), 11 deletions(-)
22
23 diff --git a/src/rc/_usage.h b/src/rc/_usage.h
24 index 0882c22..84b66b9 100644
25 --- a/src/rc/_usage.h
26 +++ b/src/rc/_usage.h
27 @@ -38,7 +38,7 @@
28 "Disable color output", \
29 "Display software version", \
30 "Run verbosely", \
31 - "Run quietly (Does not affect errors)"
32 + "Run quietly"
33
34 #define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
35 #define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
36
37 diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
38 index 5576d49..4b9fcdd 100644
39 --- a/src/rc/start-stop-daemon.c
40 +++ b/src/rc/start-stop-daemon.c
41 @@ -417,7 +417,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
42 }
43
44 if (pidfile) {
45 - pid = get_pid(pidfile, false);
46 + pid = get_pid(pidfile, quiet);
47 if (pid == -1)
48 return 0;
49 }
50 @@ -436,6 +436,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
51 if (tkilled == 0) {
52 if (progressed)
53 printf("\n");
54 + if (! quiet)
55 eerror("%s: no matching processes found", applet);
56 }
57 return tkilled;
58 @@ -506,10 +507,12 @@ run_stop_schedule(const char *exec, const char *const *argv,
59
60 if (progressed)
61 printf("\n");
62 - if (nrunning == 1)
63 - eerror("%s: %d process refused to stop", applet, nrunning);
64 - else
65 - eerror("%s: %d process(es) refused to stop", applet, nrunning);
66 + if (! quiet) {
67 + if (nrunning == 1)
68 + eerror("%s: %d process refused to stop", applet, nrunning);
69 + else
70 + eerror("%s: %d process(es) refused to stop", applet, nrunning);
71 + }
72
73 return -nrunning;
74 }
75 @@ -1289,7 +1292,7 @@ start_stop_daemon(int argc, char **argv)
76 /* We don't redirect stdin as some daemons may need it */
77 if (background || quiet || redirect_stdout)
78 dup2(stdout_fd, STDOUT_FILENO);
79 - if (background || redirect_stderr)
80 + if (background || quiet || redirect_stderr)
81 dup2(stderr_fd, STDERR_FILENO);
82
83 for (i = getdtablesize() - 1; i >= 3; --i)
84 @@ -1320,9 +1323,11 @@ start_stop_daemon(int argc, char **argv)
85 return -1;
86 }
87 } while (!WIFEXITED(i) && !WIFSIGNALED(i));
88 - if (!WIFEXITED(i) || WEXITSTATUS(i) != 0)
89 - eerrorx("%s: failed to start `%s'", applet, exec);
90 -
91 + if (!WIFEXITED(i) || WEXITSTATUS(i) != 0) {
92 + if (!quiet)
93 + eerrorx("%s: failed to start `%s'", applet, exec);
94 + exit(EXIT_FAILURE);
95 + }
96 pid = spid;
97 }
98
99 @@ -1356,7 +1361,7 @@ start_stop_daemon(int argc, char **argv)
100 alive = true;
101 } else {
102 if (pidfile) {
103 - pid = get_pid(pidfile, false);
104 + pid = get_pid(pidfile, true);
105 if (pid == -1) {
106 eerrorx("%s: did not "
107 "create a valid"