From 54d7aa39dd54ceaf7b7e509b3792bace9f34bad0 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 21 Apr 2008 10:56:28 +0000 Subject: [PATCH] If we don't have permission to inspect the pidfile, don't report crashed. Gentoo #218028. --- src/librc/librc-daemon.c | 3 +-- src/rc/rc-status.c | 8 ++++++-- src/rc/runscript.c | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index a58ba15c..bc632463 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -561,14 +561,13 @@ bool rc_service_daemons_crashed(const char *service) if ((fp = fopen(pidfile, "r"))) { if (fscanf(fp, "%d", &pid) == 1) retval = false; - fclose (fp); } free(pidfile); pidfile = NULL; /* We have the pid, so no need to match on name */ - free (name); + free(name); name = NULL; } else { if (exec) { diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index e4917c86..a64ab1b5 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -103,9 +103,13 @@ static void print_service(const char *service) snprintf(status, sizeof(status), "inactive "); color = ECOLOR_WARN; } else if (state & RC_SERVICE_STARTED) { - if (test_crashed && rc_service_daemons_crashed(service)) + errno = 0; + if (test_crashed && + rc_service_daemons_crashed(service) && + errno != EACCES) + { snprintf(status, sizeof(status), " crashed "); - else { + } else { snprintf(status, sizeof(status), " started "); color = ECOLOR_GOOD; } diff --git a/src/rc/runscript.c b/src/rc/runscript.c index 2f96d7ac..5977715a 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -559,8 +559,10 @@ static RC_SERVICE svc_status(void) snprintf(status, sizeof(status), "inactive"); e = &ewarn; } else if (state & RC_SERVICE_STARTED) { + errno = 0; if (_rc_can_find_pids() && - rc_service_daemons_crashed(service)) + rc_service_daemons_crashed(service) && + errno != EACCES) { snprintf(status, sizeof(status), "crashed"); e = &eerror;