From fa6611b5af94548e901e587fcd36f4fb59124975 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 2 Dec 2018 10:13:10 -0600 Subject: rc-status: add --supervised option to show supervised services --- man/rc-status.8 | 2 ++ src/rc/rc-status.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/man/rc-status.8 b/man/rc-status.8 index 6cf69a59..68ecc49a 100644 --- a/man/rc-status.8 +++ b/man/rc-status.8 @@ -43,6 +43,8 @@ List all defined runlevels. Show all manually started services. .It Fl r , -runlevel Print the current runlevel name. +.It Fl S , -supervised +Show all supervised services. .It Fl s , -servicelist Show all services. .It Fl u , -unused diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index 56395873..9dbf7c6b 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -29,7 +29,7 @@ const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "aclmrsu" getoptstring_COMMON; +const char *getoptstring = "aclmrsSu" getoptstring_COMMON; const struct option longopts[] = { {"all", 0, NULL, 'a'}, {"crashed", 0, NULL, 'c'}, @@ -37,6 +37,7 @@ const struct option longopts[] = { {"manual", 0, NULL, 'm'}, {"runlevel", 0, NULL, 'r'}, {"servicelist", 0, NULL, 's'}, + {"supervised", 0, NULL, 'S'}, {"unused", 0, NULL, 'u'}, longopts_COMMON }; @@ -47,6 +48,7 @@ const char * const longopts_help[] = { "Show manually started services", "Show the name of the current runlevel", "Show service list", + "show supervised services", "Show services not assigned to any runlevel", longopts_help_COMMON }; @@ -296,6 +298,14 @@ int main(int argc, char **argv) printf("%s\n", runlevel); goto exit; /* NOTREACHED */ + case 'S': + services = rc_services_in_state(RC_SERVICE_STARTED); + TAILQ_FOREACH(s, services, entries) + if (rc_service_value_get(s->value, "child_pid")) { + printf("%s\n", s->value); + } + goto exit; + /* NOTREACHED */ case 's': services = rc_services_in_runlevel(NULL); print_services(NULL, services); -- cgit v1.2.3