From d5c396cbfc49ce88f58d944c8ab01d2c36ccdc7b Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Tue, 18 Dec 2018 11:29:10 -0600 Subject: Add debug logging to start-stop-daemon and rc-supervisor This will make it easier to track down why the supervisor intermittently hangs after it runs for a long time. --- src/rc/rc-schedules.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/rc') diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c index 84c7ea18..167e5eb4 100644 --- a/src/rc/rc-schedules.c +++ b/src/rc/rc-schedules.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -270,8 +271,11 @@ 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 { - if (!quiet) - ebeginv("Sending signal %d to PID %d", sig, pi->pid); + if (sig) { + syslog(LOG_DEBUG, "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); @@ -279,6 +283,9 @@ int do_stop(const char *applet, const char *exec, const char *const *argv, eendv(killed ? 0 : 1, "%s: failed to send signal %d to PID %d: %s", applet, sig, pi->pid, strerror(errno)); + else if (!killed) + syslog(LOG_ERR, "Failed to send signal %d to PID %d: %s", + sig, pi->pid, strerror(errno)); if (!killed) { nkilled = -1; } else { @@ -310,12 +317,18 @@ int run_stop_schedule(const char *applet, if (!(pid > 0 || exec || uid || (argv && *argv))) return 0; - if (exec) + if (exec) { einfov("Will stop %s", exec); - if (pid > 0) + syslog(LOG_DEBUG, "Will stop %s", exec); + } + if (pid > 0) { einfov("Will stop PID %d", pid); - if (uid) + syslog(LOG_DEBUG, "Will stop PID %d", pid); + } + if (uid) { einfov("Will stop processes owned by UID %d", uid); + syslog(LOG_DEBUG, "Will stop processes owned by UID %d", uid); + } if (argv && *argv) { einfovn("Will stop processes of `"); if (rc_yesno(getenv("EINFO_VERBOSE"))) { -- cgit v1.2.3