summaryrefslogtreecommitdiff
path: root/src/rc/rc-status.c
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/rc/rc-status.c
parent4079b4d65d6f8f8b9f8b29bfdce2abc773cdabad (diff)
downloadopenrc-85a6addd235e1c13d2e67e5e9b6d4c963b47140d.tar.gz
openrc-85a6addd235e1c13d2e67e5e9b6d4c963b47140d.tar.bz2
openrc-85a6addd235e1c13d2e67e5e9b6d4c963b47140d.tar.xz
Only test crashed services if we can see pid 1.
Diffstat (limited to 'src/rc/rc-status.c')
-rw-r--r--src/rc/rc-status.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index c7173e2..ef58a14 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) {