aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/rc-status.c2
-rw-r--r--src/rc/rc.c16
-rw-r--r--src/rc/runscript.c148
3 files changed, 86 insertions, 80 deletions
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 9f7167f6..c7173e29 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -185,6 +185,8 @@ int rc_status (int argc, char **argv)
TAILQ_FOREACH(l, levels, entries) {
print_level(l->value);
services = rc_services_in_runlevel(l->value);
+ if (! services)
+ continue;
if (deptree) {
if (! types) {
types = rc_stringlist_new();
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 04b814e6..30bedcbf 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -778,7 +778,7 @@ static void do_stop_services(const char *newlevel, bool going_down, bool paralle
continue;
/* We always stop the service when in these runlevels */
- if (going_down) {
+ if (going_down || ! start_services) {
pid = rc_service_stop(service->value);
if (pid > 0 && ! parallel)
rc_waitpid(pid);
@@ -1097,18 +1097,20 @@ int main(int argc, char **argv)
} else
stop_services = tmplist;
}
- rc_stringlist_sort(&stop_services);
-
+ if (stop_services)
+ rc_stringlist_sort(&stop_services);
types_nua = rc_stringlist_new();
rc_stringlist_add(types_nua, "ineed");
rc_stringlist_add(types_nua, "iuse");
rc_stringlist_add(types_nua, "iafter");
- tmplist = rc_deptree_depends(deptree, types_nua, stop_services,
- runlevel, depoptions | RC_DEP_STOP);
- rc_stringlist_free(stop_services);
- stop_services = tmplist;
+ if (stop_services) {
+ tmplist = rc_deptree_depends(deptree, types_nua, stop_services,
+ runlevel, depoptions | RC_DEP_STOP);
+ rc_stringlist_free(stop_services);
+ stop_services = tmplist;
+ }
/* Load our list of coldplugged services */
coldplugged_services = rc_services_in_state(RC_SERVICE_COLDPLUGGED);
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 704d32fe..08d2c4e8 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -694,14 +694,14 @@ static void svc_start(bool deps)
depoptions |= RC_DEP_STRICT;
if (deps) {
- if (! deptree && ((deptree = _rc_deptree_load (NULL)) == NULL))
+ if (! deptree && ((deptree = _rc_deptree_load(NULL)) == NULL))
eerrorx("failed to load deptree");
if (! types_b)
setup_types();
services = rc_deptree_depends(deptree, types_b, applet_list,
- runlevel, 0);
+ runlevel, 0);
if (services && TAILQ_FIRST(services)) {
eerrorn("ERROR: `%s' needs ", applet);
first = true;
@@ -718,9 +718,9 @@ static void svc_start(bool deps)
services = NULL;
need_services = rc_deptree_depends(deptree, types_n, applet_list,
- runlevel, depoptions);
+ runlevel, depoptions);
use_services = rc_deptree_depends(deptree, types_nu, applet_list,
- runlevel, depoptions);
+ runlevel, depoptions);
if (! rc_runlevel_starting() && use_services)
TAILQ_FOREACH(svc, use_services, entries)
@@ -732,88 +732,90 @@ static void svc_start(bool deps)
/* Now wait for them to start */
services = rc_deptree_depends(deptree, types_nua, applet_list,
- runlevel, depoptions);
+ runlevel, depoptions);
- /* We use tmplist to hold our scheduled by list */
- tmplist = NULL;
- TAILQ_FOREACH(svc, services, entries) {
- RC_SERVICE svcs = rc_service_state(svc->value);
- if (svcs & RC_SERVICE_STARTED)
- continue;
-
- /* Don't wait for services which went inactive but are now in
- * starting state which we are after */
- if (svcs & RC_SERVICE_STARTING &&
- svcs & RC_SERVICE_WASINACTIVE) {
- TAILQ_FOREACH(svc2, use_services, entries) {
- if (strcmp (svc->value, svc2->value) == 0)
- break;
- }
- if (! svc2)
+ if (services) {
+ /* We use tmplist to hold our scheduled by list */
+ tmplist = NULL;
+ TAILQ_FOREACH(svc, services, entries) {
+ RC_SERVICE svcs = rc_service_state(svc->value);
+ if (svcs & RC_SERVICE_STARTED)
continue;
- }
- if (! svc_wait(svc->value))
- eerror ("%s: timed out waiting for %s",
- applet, svc->value);
- if (! need_services)
- continue;
- if ((svcs = rc_service_state(svc->value)) & RC_SERVICE_STARTED)
- continue;
- TAILQ_FOREACH(svc2, need_services, entries) {
- if (strcmp (svc->value, svc2->value) == 0) {
- if (svcs & RC_SERVICE_INACTIVE ||
- svcs & RC_SERVICE_WASINACTIVE)
- {
- if (! tmplist)
- tmplist = rc_stringlist_new();
- rc_stringlist_add(tmplist, svc->value);
- } else
- eerrorx("ERROR: cannot start %s as"
- " %s would not start",
+ /* Don't wait for services which went inactive but are now in
+ * starting state which we are after */
+ if (svcs & RC_SERVICE_STARTING &&
+ svcs & RC_SERVICE_WASINACTIVE) {
+ TAILQ_FOREACH(svc2, use_services, entries) {
+ if (strcmp (svc->value, svc2->value) == 0)
+ break;
+ }
+ if (! svc2)
+ continue;
+ }
+
+ if (! svc_wait(svc->value))
+ eerror ("%s: timed out waiting for %s",
applet, svc->value);
+ if (! need_services)
+ continue;
+ if ((svcs = rc_service_state(svc->value)) & RC_SERVICE_STARTED)
+ continue;
+ TAILQ_FOREACH(svc2, need_services, entries) {
+ if (strcmp (svc->value, svc2->value) == 0) {
+ if (svcs & RC_SERVICE_INACTIVE ||
+ svcs & RC_SERVICE_WASINACTIVE)
+ {
+ if (! tmplist)
+ tmplist = rc_stringlist_new();
+ rc_stringlist_add(tmplist, svc->value);
+ } else
+ eerrorx("ERROR: cannot start %s as"
+ " %s would not start",
+ applet, svc->value);
+ }
}
}
- }
- if (tmplist && TAILQ_FIRST(tmplist)) {
- /* Set the state now, then unlink our exclusive so that
- our scheduled list is preserved */
- rc_service_mark(service, RC_SERVICE_STOPPED);
- unlink_mtime_test();
+ if (tmplist && TAILQ_FIRST(tmplist)) {
+ /* Set the state now, then unlink our exclusive so that
+ our scheduled list is preserved */
+ rc_service_mark(service, RC_SERVICE_STOPPED);
+ unlink_mtime_test();
- rc_stringlist_free(use_services);
- use_services = NULL;
- len = 0;
- n = 0;
- TAILQ_FOREACH(svc, tmplist, entries) {
- rc_service_schedule_start(svc->value, service);
- use_services = rc_deptree_depend(deptree, "iprovide",
- svc->value);
- TAILQ_FOREACH (svc2, use_services, entries)
- rc_service_schedule_start(svc2->value, service);
rc_stringlist_free(use_services);
use_services = NULL;
- len += strlen(svc->value) + 2;
- n++;
- }
+ len = 0;
+ n = 0;
+ TAILQ_FOREACH(svc, tmplist, entries) {
+ rc_service_schedule_start(svc->value, service);
+ use_services = rc_deptree_depend(deptree, "iprovide",
+ svc->value);
+ TAILQ_FOREACH (svc2, use_services, entries)
+ rc_service_schedule_start(svc2->value, service);
+ rc_stringlist_free(use_services);
+ use_services = NULL;
+ len += strlen(svc->value) + 2;
+ n++;
+ }
- len += 5;
- tmp = p = xmalloc(sizeof(char) * len);
- TAILQ_FOREACH(svc, tmplist, entries) {
- if (p != tmp)
- p += snprintf(p, len, ", ");
- p += snprintf(p, len, "%s", svc->value);
+ len += 5;
+ tmp = p = xmalloc(sizeof(char) * len);
+ TAILQ_FOREACH(svc, tmplist, entries) {
+ if (p != tmp)
+ p += snprintf(p, len, ", ");
+ p += snprintf(p, len, "%s", svc->value);
+ }
+ free(tmp);
+ rc_stringlist_free(tmplist);
+ tmplist = NULL;
+ ewarnx("WARNING: %s is scheduled to start when %s has started",
+ applet, tmp);
}
- free(tmp);
- rc_stringlist_free(tmplist);
- tmplist = NULL;
- ewarnx("WARNING: %s is scheduled to start when %s has started",
- applet, tmp);
- }
- rc_stringlist_free(services);
- services = NULL;
+ rc_stringlist_free(services);
+ services = NULL;
+ }
}
if (ibsave)