aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-24 10:17:53 +0000
committerRoy Marples <roy@marples.name>2009-04-24 10:17:53 +0000
commit9966a902ab375128e128edc4ca85676656b759db (patch)
treef954bee4eeaa3142f945f7fa772470746c8061f6 /src
parente2629b0a3b8f4e3df12878fb865b6a244d8a54a8 (diff)
rc-status -c now lists services that have crashed.
It returns 0 if there are crashed services, otherwise 1. This it easy to restart crashed services automatically. More for #120.
Diffstat (limited to 'src')
-rw-r--r--src/rc/rc-status.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 2f386a41..320b92c8 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -172,9 +172,10 @@ print_services(const char *runlevel, RC_STRINGLIST *svcs)
#include "_usage.h"
#define extraopts "[runlevel1] [runlevel2] ..."
-#define getoptstring "alrsu" getoptstring_COMMON
+#define getoptstring "aclrsu" getoptstring_COMMON
static const struct option longopts[] = {
{"all", 0, NULL, 'a'},
+ {"crashed", 0, NULL, 'c'},
{"list", 0, NULL, 'l'},
{"runlevel", 0, NULL, 'r'},
{"servicelist", 0, NULL, 's'},
@@ -183,6 +184,7 @@ static const struct option longopts[] = {
};
static const char * const longopts_help[] = {
"Show services from all run levels",
+ "Show crashed services",
"Show list of run levels",
"Show the name of the current runlevel",
"Show service list",
@@ -196,7 +198,7 @@ rc_status(int argc, char **argv)
{
RC_STRING *s, *l, *t;
char *p, *runlevel = NULL;
- int opt, aflag = 0;
+ int opt, aflag = 0, retval = 0;
test_crashed = _rc_can_find_pids();
@@ -207,10 +209,14 @@ rc_status(int argc, char **argv)
aflag++;
levels = rc_runlevel_list();
break;
- case 'l':
- levels = rc_runlevel_list();
- TAILQ_FOREACH (l, levels, entries)
- printf("%s\n", l->value);
+ case 'c':
+ services = rc_services_in_state(RC_SERVICE_STARTED);
+ retval = 1;
+ TAILQ_FOREACH(s, services, entries)
+ if (rc_service_daemons_crashed(s->value)) {
+ printf("%s\n", s->value);
+ retval = 0;
+ }
goto exit;
/* NOTREACHED */
case 'r':
@@ -344,5 +350,5 @@ exit:
rc_deptree_free(deptree);
#endif
- return(EXIT_SUCCESS);
+ return retval;
}