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.
William Hubbs
5 years ago
27 | 27 | #include <stdio.h> |
28 | 28 | #include <stdlib.h> |
29 | 29 | #include <string.h> |
30 | #include <syslog.h> | |
30 | 31 | #include <time.h> |
31 | 32 | #include <unistd.h> |
32 | 33 | #include <sys/stat.h> |
269 | 270 | einfo("Would send signal %d to PID %d", sig, pi->pid); |
270 | 271 | nkilled++; |
271 | 272 | } else { |
272 | if (!quiet) | |
273 | ebeginv("Sending signal %d to PID %d", sig, pi->pid); | |
273 | if (sig) { | |
274 | syslog(LOG_DEBUG, "Sending signal %d to PID %d", sig, pi->pid); | |
275 | if (!quiet) | |
276 | ebeginv("Sending signal %d to PID %d", sig, pi->pid); | |
277 | } | |
274 | 278 | errno = 0; |
275 | 279 | killed = (kill(pi->pid, sig) == 0 || |
276 | 280 | errno == ESRCH ? true : false); |
278 | 282 | eendv(killed ? 0 : 1, |
279 | 283 | "%s: failed to send signal %d to PID %d: %s", |
280 | 284 | applet, sig, pi->pid, strerror(errno)); |
285 | else if (!killed) | |
286 | syslog(LOG_ERR, "Failed to send signal %d to PID %d: %s", | |
287 | sig, pi->pid, strerror(errno)); | |
281 | 288 | if (!killed) { |
282 | 289 | nkilled = -1; |
283 | 290 | } else { |
309 | 316 | if (!(pid > 0 || exec || uid || (argv && *argv))) |
310 | 317 | return 0; |
311 | 318 | |
312 | if (exec) | |
319 | if (exec) { | |
313 | 320 | einfov("Will stop %s", exec); |
314 | if (pid > 0) | |
321 | syslog(LOG_DEBUG, "Will stop %s", exec); | |
322 | } | |
323 | if (pid > 0) { | |
315 | 324 | einfov("Will stop PID %d", pid); |
316 | if (uid) | |
325 | syslog(LOG_DEBUG, "Will stop PID %d", pid); | |
326 | } | |
327 | if (uid) { | |
317 | 328 | einfov("Will stop processes owned by UID %d", uid); |
329 | syslog(LOG_DEBUG, "Will stop processes owned by UID %d", uid); | |
330 | } | |
318 | 331 | if (argv && *argv) { |
319 | 332 | einfovn("Will stop processes of `"); |
320 | 333 | if (rc_yesno(getenv("EINFO_VERBOSE"))) { |