add quiet switch to do_stop in src-schedules.c

This allows supervise-daemon to run this code without attempting to
print some status messages used by start-stop-daemon.
This commit is contained in:
William Hubbs 2017-09-14 18:24:31 -05:00
parent 6a5ca2ab36
commit b0a077a35f
4 changed files with 13 additions and 13 deletions

View File

@ -253,7 +253,7 @@ void parse_schedule(const char *applet, const char *string, int timeout)
/* return number of processes killed, -1 on error */
int do_stop(const char *applet, const char *exec, const char *const *argv,
pid_t pid, uid_t uid,int sig, bool test)
pid_t pid, uid_t uid,int sig, bool test, bool quiet)
{
RC_PIDLIST *pids;
RC_PID *pi;
@ -274,11 +274,13 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
einfo("Would send signal %d to PID %d", sig, pi->pid);
nkilled++;
} else {
ebeginv("Sending signal %d to PID %d", sig, pi->pid);
if (!quiet)
ebeginv("Sending signal %d to PID %d", sig, pi->pid);
errno = 0;
killed = (kill(pi->pid, sig) == 0 ||
errno == ESRCH ? true : false);
eendv(killed ? 0 : 1,
if (! quiet)
eendv(killed ? 0 : 1,
"%s: failed to send signal %d to PID %d: %s",
applet, sig, pi->pid, strerror(errno));
if (!killed) {
@ -335,7 +337,8 @@ int run_stop_schedule(const char *applet,
case SC_SIGNAL:
nrunning = 0;
nkilled = do_stop(applet, exec, argv, pid, uid, item->value, test);
nkilled = do_stop(applet, exec, argv, pid, uid, item->value, test,
quiet);
if (nkilled == 0) {
if (tkilled == 0) {
if (progressed)
@ -364,7 +367,7 @@ int run_stop_schedule(const char *applet,
nloops++)
{
if ((nrunning = do_stop(applet, exec, argv,
pid, uid, 0, test)) == 0)
pid, uid, 0, test, quiet)) == 0)
return 0;

View File

@ -18,7 +18,7 @@ void free_schedulelist(void);
int parse_signal(const char *applet, const char *sig);
void parse_schedule(const char *applet, const char *string, int timeout);
int do_stop(const char *applet, const char *exec, const char *const *argv,
pid_t pid, uid_t uid,int sig, bool test);
pid_t pid, uid_t uid,int sig, bool test, bool quiet);
int run_stop_schedule(const char *applet,
const char *exec, const char *const *argv,
pid_t pid, uid_t uid,

View File

@ -684,7 +684,7 @@ int main(int argc, char **argv)
pid = 0;
if (do_stop(applet, exec, (const char * const *)margv, pid, uid,
0, test) > 0)
0, test, false) > 0)
eerrorx("%s: %s is already running", applet, exec);
if (test) {
@ -964,7 +964,7 @@ int main(int argc, char **argv)
} else
pid = 0;
if (do_stop(applet, exec, (const char *const *)margv,
pid, uid, 0, test) > 0)
pid, uid, 0, test, false) > 0)
alive = true;
}

View File

@ -440,11 +440,6 @@ int main(int argc, char **argv)
applet = basename_c(argv[0]);
atexit(cleanup);
signal_setup(SIGINT, handle_signal);
signal_setup(SIGQUIT, handle_signal);
signal_setup(SIGTERM, handle_signal);
openlog(applet, LOG_PID, LOG_DAEMON);
if ((tmp = getenv("SSD_NICELEVEL")))
if (sscanf(tmp, "%d", &nicelevel) != 1)
eerror("%s: invalid nice level `%s' (SSD_NICELEVEL)",
@ -729,6 +724,8 @@ int main(int argc, char **argv)
if (child_pid != 0) {
/* this is the supervisor */
umask(numask);
openlog(applet, LOG_PID, LOG_DAEMON);
signal_setup(SIGTERM, handle_signal);
fp = fopen(pidfile, "w");
if (! fp)