start-stop-daemon: remove the verbose variable
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.
This commit is contained in:
parent
d6436bed09
commit
9e989227ab
@ -334,8 +334,7 @@ get_pid(const char *pidfile)
|
|||||||
/* return number of processed killed, -1 on error */
|
/* return number of processed killed, -1 on error */
|
||||||
static int
|
static int
|
||||||
do_stop(const char *exec, const char *const *argv,
|
do_stop(const char *exec, const char *const *argv,
|
||||||
pid_t pid, uid_t uid,int sig,
|
pid_t pid, uid_t uid,int sig, bool test)
|
||||||
bool verbose, bool test)
|
|
||||||
{
|
{
|
||||||
RC_PIDLIST *pids;
|
RC_PIDLIST *pids;
|
||||||
RC_PID *pi;
|
RC_PID *pi;
|
||||||
@ -356,16 +355,13 @@ do_stop(const char *exec, const char *const *argv,
|
|||||||
einfo("Would send signal %d to PID %d", sig, pi->pid);
|
einfo("Would send signal %d to PID %d", sig, pi->pid);
|
||||||
nkilled++;
|
nkilled++;
|
||||||
} else {
|
} else {
|
||||||
if (verbose)
|
ebeginv("Sending signal %d to PID %d", sig, pi->pid);
|
||||||
ebegin("Sending signal %d to PID %d",
|
|
||||||
sig, pi->pid);
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
killed = (kill(pi->pid, sig) == 0 ||
|
killed = (kill(pi->pid, sig) == 0 ||
|
||||||
errno == ESRCH ? true : false);
|
errno == ESRCH ? true : false);
|
||||||
if (verbose)
|
eendv(killed ? 0 : 1,
|
||||||
eend(killed ? 0 : 1,
|
"%s: failed to send signal %d to PID %d: %s",
|
||||||
"%s: failed to send signal %d to PID %d: %s",
|
applet, sig, pi->pid, strerror(errno));
|
||||||
applet, sig, pi->pid, strerror(errno));
|
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
nkilled = -1;
|
nkilled = -1;
|
||||||
} else {
|
} else {
|
||||||
@ -383,7 +379,7 @@ do_stop(const char *exec, const char *const *argv,
|
|||||||
static int
|
static int
|
||||||
run_stop_schedule(const char *exec, const char *const *argv,
|
run_stop_schedule(const char *exec, const char *const *argv,
|
||||||
const char *pidfile, uid_t uid,
|
const char *pidfile, uid_t uid,
|
||||||
bool verbose, bool test, bool progress)
|
bool test, bool progress)
|
||||||
{
|
{
|
||||||
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
|
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
|
||||||
int nkilled = 0;
|
int nkilled = 0;
|
||||||
@ -395,15 +391,15 @@ run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
const char *const *p;
|
const char *const *p;
|
||||||
bool progressed = false;
|
bool progressed = false;
|
||||||
|
|
||||||
if (verbose) {
|
if (exec)
|
||||||
if (exec)
|
einfov("Will stop %s", exec);
|
||||||
einfo ("Will stop %s", exec);
|
if (pidfile)
|
||||||
if (pidfile)
|
einfov("Will stop PID in pidfile `%s'", pidfile);
|
||||||
einfo("Will stop PID in pidfile `%s'", pidfile);
|
if (uid)
|
||||||
if (uid)
|
einfov("Will stop processes owned by UID %d", uid);
|
||||||
einfo("Will stop processes owned by UID %d", uid);
|
if (argv && *argv) {
|
||||||
if (argv && *argv) {
|
einfovn("Will stop processes of `");
|
||||||
einfon("Will stop processes of `");
|
if (rc_yesno(getenv("EINFO_VERBOSE"))) {
|
||||||
for (p = argv; p && *p; p++) {
|
for (p = argv; p && *p; p++) {
|
||||||
if (p != argv)
|
if (p != argv)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
@ -427,8 +423,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
|
|
||||||
case SC_SIGNAL:
|
case SC_SIGNAL:
|
||||||
nrunning = 0;
|
nrunning = 0;
|
||||||
nkilled = do_stop(exec, argv, pid, uid, item->value,
|
nkilled = do_stop(exec, argv, pid, uid, item->value, test);
|
||||||
verbose, test);
|
|
||||||
if (nkilled == 0) {
|
if (nkilled == 0) {
|
||||||
if (tkilled == 0) {
|
if (tkilled == 0) {
|
||||||
if (progressed)
|
if (progressed)
|
||||||
@ -457,7 +452,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
nloops++)
|
nloops++)
|
||||||
{
|
{
|
||||||
if ((nrunning = do_stop(exec, argv,
|
if ((nrunning = do_stop(exec, argv,
|
||||||
pid, uid, 0, false, true)) == 0)
|
pid, uid, 0, true)) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
@ -674,7 +669,6 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
bool stop = false;
|
bool stop = false;
|
||||||
bool oknodo = false;
|
bool oknodo = false;
|
||||||
bool test = false;
|
bool test = false;
|
||||||
bool verbose = false;
|
|
||||||
char *exec = NULL;
|
char *exec = NULL;
|
||||||
char *startas = NULL;
|
char *startas = NULL;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
@ -911,7 +905,6 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
endpwent();
|
endpwent();
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
verbose = rc_yesno(getenv("EINFO_VERBOSE"));
|
|
||||||
|
|
||||||
/* Allow start-stop-daemon --signal HUP --exec /usr/sbin/dnsmasq
|
/* Allow start-stop-daemon --signal HUP --exec /usr/sbin/dnsmasq
|
||||||
* instead of forcing --stop --oknodo as well */
|
* instead of forcing --stop --oknodo as well */
|
||||||
@ -1055,7 +1048,7 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
parse_schedule(NULL, sig);
|
parse_schedule(NULL, sig);
|
||||||
i = run_stop_schedule(exec, (const char *const *)margv,
|
i = run_stop_schedule(exec, (const char *const *)margv,
|
||||||
pidfile, uid, verbose, test, progress);
|
pidfile, uid, test, progress);
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
/* We failed to stop something */
|
/* We failed to stop something */
|
||||||
@ -1082,7 +1075,7 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
pid = 0;
|
pid = 0;
|
||||||
|
|
||||||
if (do_stop(exec, (const char * const *)margv, pid, uid,
|
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);
|
eerrorx("%s: %s is already running", applet, exec);
|
||||||
|
|
||||||
if (test) {
|
if (test) {
|
||||||
@ -1110,10 +1103,8 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
ebeginv("Detaching to start `%s'", exec);
|
||||||
ebegin("Detaching to start `%s'", exec);
|
eindentv();
|
||||||
eindent();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove existing pidfile */
|
/* Remove existing pidfile */
|
||||||
if (pidfile)
|
if (pidfile)
|
||||||
@ -1361,7 +1352,7 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
} else
|
} else
|
||||||
pid = 0;
|
pid = 0;
|
||||||
if (do_stop(exec, (const char *const *)margv,
|
if (do_stop(exec, (const char *const *)margv,
|
||||||
pid, uid, 0, false, true) > 0)
|
pid, uid, 0, true) > 0)
|
||||||
alive = true;
|
alive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user