aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-03-21 13:04:29 +0000
committerRoy Marples <roy@marples.name>2008-03-21 13:04:29 +0000
commit85a6addd235e1c13d2e67e5e9b6d4c963b47140d (patch)
treedcff86dca7f23f80f5fed7374cb243a2b0e70812 /src
parent4079b4d65d6f8f8b9f8b29bfdce2abc773cdabad (diff)
Only test crashed services if we can see pid 1.
Diffstat (limited to 'src')
-rw-r--r--src/rc/builtins.h3
-rw-r--r--src/rc/rc-status.c34
-rw-r--r--src/rc/runscript.c2
3 files changed, 35 insertions, 4 deletions
diff --git a/src/rc/builtins.h b/src/rc/builtins.h
index 5b605455..e87e1ca4 100644
--- a/src/rc/builtins.h
+++ b/src/rc/builtins.h
@@ -40,3 +40,6 @@ void run_applets(int, char **);
/* Handy function so we can wrap einfo around our deptree */
RC_DEPTREE *_rc_deptree_load (int *);
+
+/* Test to see if we can see pid 1 or not */
+bool _rc_findpid1(void);
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index c7173e29..ef58a147 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -41,9 +41,35 @@
#include "rc-misc.h"
extern const char *applet;
-
+static bool test_crashed = false;
static const char *const types_nua[] = { "ineed", "iuse", "iafter", NULL };
+bool _rc_findpid1(void)
+{
+ RC_PIDLIST *pids;
+ RC_PID *pid;
+ RC_PID *pid2;
+ bool retval = false;
+
+ /* If we cannot see process 1, then we don't test to see if
+ * services crashed or not */
+ pids = rc_find_pids(NULL, NULL, 0, 1);
+ if (pids) {
+ pid = LIST_FIRST(pids);
+ if (pid) {
+ retval = true;
+ while (pid) {
+ pid2 = LIST_NEXT(pid, entries);
+ free(pid);
+ pid = pid2;
+ }
+ }
+ free(pids);
+ }
+
+ return retval;
+}
+
static void print_level(char *level)
{
printf ("Runlevel: ");
@@ -73,7 +99,7 @@ static void print_service(char *service)
snprintf(status, sizeof(status), "inactive ");
color = ECOLOR_WARN;
} else if (state & RC_SERVICE_STARTED) {
- if (rc_service_daemons_crashed(service))
+ if (test_crashed && rc_service_daemons_crashed(service))
snprintf(status, sizeof(status), " crashed ");
else {
snprintf(status, sizeof(status), " started ");
@@ -112,7 +138,7 @@ static const char * const longopts_help[] = {
};
#include "_usage.c"
-int rc_status (int argc, char **argv)
+int rc_status(int argc, char **argv)
{
RC_DEPTREE *deptree = NULL;
RC_STRINGLIST *levels = NULL;
@@ -125,6 +151,8 @@ int rc_status (int argc, char **argv)
int opt;
int depopts = RC_DEP_STRICT | RC_DEP_START | RC_DEP_TRACE;
+ test_crashed = _rc_findpid1();
+
while ((opt = getopt_long(argc, argv, getoptstring, longopts,
(int *) 0)) != -1)
switch (opt) {
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index b0d6fca8..9263cea1 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -559,7 +559,7 @@ static RC_SERVICE svc_status(void)
snprintf(status, sizeof(status), "inactive");
e = &ewarn;
} else if (state & RC_SERVICE_STARTED) {
- if (rc_service_daemons_crashed(service)) {
+ if (_rc_findpid1() && rc_service_daemons_crashed(service)) {
snprintf(status, sizeof (status), "crashed");
e = &eerror;
} else