Skip to content

Commit

Permalink
start-stop-daemon: remove the verbose variable
Browse files Browse the repository at this point in the history
Along the same lines as the quiet variable, this is controlled by an
environment variable for the einfo code, so we do not need a separate
boolean flag.
  • Loading branch information
williamh committed Sep 24, 2013
1 parent d6436be commit 9e98922
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions src/rc/start-stop-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ get_pid(const char *pidfile)
/* return number of processed killed, -1 on error */
static int
do_stop(const char *exec, const char *const *argv,
pid_t pid, uid_t uid,int sig,
bool verbose, bool test)
pid_t pid, uid_t uid,int sig, bool test)
{
RC_PIDLIST *pids;
RC_PID *pi;
Expand All @@ -356,16 +355,13 @@ do_stop(const char *exec, const char *const *argv,
einfo("Would send signal %d to PID %d", sig, pi->pid);
nkilled++;
} else {
if (verbose)
ebegin("Sending signal %d to PID %d",
sig, pi->pid);
ebeginv("Sending signal %d to PID %d", sig, pi->pid);
errno = 0;
killed = (kill(pi->pid, sig) == 0 ||
errno == ESRCH ? true : false);
if (verbose)
eend(killed ? 0 : 1,
"%s: failed to send signal %d to PID %d: %s",
applet, sig, pi->pid, strerror(errno));
eendv(killed ? 0 : 1,
"%s: failed to send signal %d to PID %d: %s",
applet, sig, pi->pid, strerror(errno));
if (!killed) {
nkilled = -1;
} else {
Expand All @@ -383,7 +379,7 @@ do_stop(const char *exec, const char *const *argv,
static int
run_stop_schedule(const char *exec, const char *const *argv,
const char *pidfile, uid_t uid,
bool verbose, bool test, bool progress)
bool test, bool progress)
{
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
int nkilled = 0;
Expand All @@ -395,15 +391,15 @@ run_stop_schedule(const char *exec, const char *const *argv,
const char *const *p;
bool progressed = false;

if (verbose) {
if (exec)
einfo ("Will stop %s", exec);
if (pidfile)
einfo("Will stop PID in pidfile `%s'", pidfile);
if (uid)
einfo("Will stop processes owned by UID %d", uid);
if (argv && *argv) {
einfon("Will stop processes of `");
if (exec)
einfov("Will stop %s", exec);
if (pidfile)
einfov("Will stop PID in pidfile `%s'", pidfile);
if (uid)
einfov("Will stop processes owned by UID %d", uid);
if (argv && *argv) {
einfovn("Will stop processes of `");
if (rc_yesno(getenv("EINFO_VERBOSE"))) {
for (p = argv; p && *p; p++) {
if (p != argv)
printf(" ");
Expand All @@ -427,8 +423,7 @@ run_stop_schedule(const char *exec, const char *const *argv,

case SC_SIGNAL:
nrunning = 0;
nkilled = do_stop(exec, argv, pid, uid, item->value,
verbose, test);
nkilled = do_stop(exec, argv, pid, uid, item->value, test);
if (nkilled == 0) {
if (tkilled == 0) {
if (progressed)
Expand Down Expand Up @@ -457,7 +452,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
nloops++)
{
if ((nrunning = do_stop(exec, argv,
pid, uid, 0, false, true)) == 0)
pid, uid, 0, true)) == 0)
return 0;


Expand Down Expand Up @@ -674,7 +669,6 @@ start_stop_daemon(int argc, char **argv)
bool stop = false;
bool oknodo = false;
bool test = false;
bool verbose = false;
char *exec = NULL;
char *startas = NULL;
char *name = NULL;
Expand Down Expand Up @@ -911,7 +905,6 @@ start_stop_daemon(int argc, char **argv)
endpwent();
argc -= optind;
argv += optind;
verbose = rc_yesno(getenv("EINFO_VERBOSE"));

/* Allow start-stop-daemon --signal HUP --exec /usr/sbin/dnsmasq
* instead of forcing --stop --oknodo as well */
Expand Down Expand Up @@ -1055,7 +1048,7 @@ start_stop_daemon(int argc, char **argv)
else
parse_schedule(NULL, sig);
i = run_stop_schedule(exec, (const char *const *)margv,
pidfile, uid, verbose, test, progress);
pidfile, uid, test, progress);

if (i < 0)
/* We failed to stop something */
Expand All @@ -1082,7 +1075,7 @@ start_stop_daemon(int argc, char **argv)
pid = 0;

if (do_stop(exec, (const char * const *)margv, pid, uid,
0, false, true) > 0)
0, true) > 0)
eerrorx("%s: %s is already running", applet, exec);

if (test) {
Expand Down Expand Up @@ -1110,10 +1103,8 @@ start_stop_daemon(int argc, char **argv)
exit(EXIT_SUCCESS);
}

if (verbose) {
ebegin("Detaching to start `%s'", exec);
eindent();
}
ebeginv("Detaching to start `%s'", exec);
eindentv();

/* Remove existing pidfile */
if (pidfile)
Expand Down Expand Up @@ -1361,7 +1352,7 @@ start_stop_daemon(int argc, char **argv)
} else
pid = 0;
if (do_stop(exec, (const char *const *)margv,
pid, uid, 0, false, true) > 0)
pid, uid, 0, true) > 0)
alive = true;
}

Expand Down

0 comments on commit 9e98922

Please sign in to comment.