Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rc: allow switching runlevels without stopping services

OpenRC, by default, stops all services that are not listed in a runlevel
when rc is used to switch runlevels. This adds a -n/--no-stop command
line option to rc which tells it to skip stopping the services which are
not in the runlevel.

X-Gentoo-Bug: 372585
  • Loading branch information...
commit 10a4385e409b48d9aa60590c140d4ca6485a7a72 1 parent 10eabd4
@williamh williamh authored
Showing with 16 additions and 9 deletions.
  1. +5 −4 man/rc.8
  2. +11 −5 src/rc/rc.c
9 man/rc.8
@@ -29,16 +29,17 @@
.Nd stops and starts services for the specified runlevel
+.Op Fl n , -no-stop
.Op Fl o , -override
.Op Ar runlevel
-first stops any services that are not for the runlevel and then starts any
-services in the runlevel and from stacked runlevels added by
+first stops any services that are not in the specified runlevel unless
+--no-stop is specified, then starts any services in the runlevel and
+stacked runlevels added by
.Nm rc-update
that are not currently started.
-If no runlevel is specified then we use the current runlevel the system
-is currently in.
+If no runlevel is specified, we use the current runlevel.
There are some special runlevels that you should be aware of:
.Bl -tag -width "shutdown"
16 src/rc/rc.c
@@ -729,16 +729,18 @@ handle_bad_signal(int sig)
#include "_usage.h"
#define usagestring "" \
"Usage: rc [options] [<runlevel>]"
-#define getoptstring "a:o:s:S" getoptstring_COMMON
+#define getoptstring "a:no:s:S" getoptstring_COMMON
static const struct option longopts[] = {
{ "applet", 1, NULL, 'a' },
- { "override", 1, NULL, 'o' },
- { "service", 1, NULL, 's' },
- { "sys", 0, NULL, 'S' },
+ { "no-stop", 0, NULL, 'n' },
+ { "override", 1, NULL, 'o' },
+ { "service", 1, NULL, 's' },
+ { "sys", 0, NULL, 'S' },
static const char * const longopts_help[] = {
"runs the applet specified by the next argument",
+ "do not stop any services",
"override the next runlevel to change into\n"
"when leaving single user or boot runlevels",
"runs the service specified with the rest\nof the arguments",
@@ -762,6 +764,7 @@ main(int argc, char **argv)
int opt;
bool parallel;
int regen = 0;
+ bool nostop = false;
#ifdef __linux__
char *proc;
char *p;
@@ -812,6 +815,9 @@ main(int argc, char **argv)
/* Do nothing, actual logic in run_applets, this
* is a placeholder */
+ case 'n':
+ nostop = true;
+ break;
case 'o':
if (*optarg == '\0')
optarg = NULL;
@@ -1022,7 +1028,7 @@ main(int argc, char **argv)
parallel = rc_conf_yesno("rc_parallel");
/* Now stop the services that shouldn't be running */
- if (stop_services)
+ if (stop_services && !nostop)
do_stop_services(newlevel, parallel, going_down);
/* Wait for our services to finish */
Please sign in to comment.
Something went wrong with that request. Please try again.