aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pies.c54
-rw-r--r--src/pies.h11
-rw-r--r--src/prog.h2
-rw-r--r--src/progman.c20
-rw-r--r--src/sysvinit.c59
5 files changed, 67 insertions, 79 deletions
diff --git a/src/pies.c b/src/pies.c
index 96e9281..3734b47 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -1538,3 +1538,3 @@ pies_reload (void)
if (init_process)
- sysvinit_runlevel_setup (PIES_COMP_DEFAULT, NULL);
+ sysvinit_runlevel_setup (PIES_COMP_DEFAULT);
progman_create_sockets ();
@@ -1551,5 +1551,4 @@ static struct config_syntax *current_syntax = &config_syntax_tab[CONF_PIES];
-int action = ACTION_CONT;
-int children_cleanup = 0;
-int got_alarm = 0;
+static int action = ACTION_CONT;
+static int children_op = PIES_CHLD_NONE;
@@ -1561,2 +1560,8 @@ pies_schedule_action (int act)
+void
+pies_schedule_children (int op)
+{
+ children_op |= op;
+}
+
RETSIGTYPE
@@ -1569,3 +1574,3 @@ sig_handler (int sig)
case SIGCHLD:
- children_cleanup = 1;
+ pies_schedule_children (PIES_CHLD_CLEANUP);
break;
@@ -1590,3 +1595,3 @@ sig_handler (int sig)
case SIGALRM:
- got_alarm = 1;
+ pies_schedule_children (PIES_CHLD_WAKEUP);
break;
@@ -2152,5 +2157,3 @@ main (int argc, char **argv)
- if (init_process)
- ctl_open ();
- else
+ if (!init_process)
{
@@ -2175,6 +2178,6 @@ main (int argc, char **argv)
{
- got_alarm = 1;
+ pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
}
- else if (!children_cleanup)
+ else if (children_op == PIES_CHLD_NONE)
pies_pause ();
@@ -2192,3 +2195,3 @@ main (int argc, char **argv)
pies_reload ();
- got_alarm = 1;
+ pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
@@ -2206,5 +2209,4 @@ main (int argc, char **argv)
debug (1, ("ctrl-alt-del"));
- sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_ctrlaltdel),
- NULL);
- got_alarm = 1;
+ sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_ctrlaltdel));
+ pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
@@ -2214,5 +2216,4 @@ main (int argc, char **argv)
debug (1, ("kbrequest"));
- sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_kbrequest),
- NULL);
- got_alarm = 1;
+ sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_kbrequest));
+ pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
@@ -2223,3 +2224,3 @@ main (int argc, char **argv)
sysvinit_power ();
- got_alarm = 1;
+ pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
@@ -2228,12 +2229,7 @@ main (int argc, char **argv)
{
- if (children_cleanup)
- {
- children_cleanup = 0;
- progman_cleanup (0);
- }
- if (got_alarm)
- {
- progman_wake_sleeping (1);
- got_alarm = 0;
- }
+ if (children_op & PIES_CHLD_CLEANUP)
+ progman_cleanup (0);
+ if (children_op & PIES_CHLD_WAKEUP)
+ progman_wake_sleeping (1);
+ children_op = PIES_CHLD_NONE;
}
diff --git a/src/pies.h b/src/pies.h
index 14ea7b7..bcce32a 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -182,4 +182,3 @@ enum pies_comp_mode
#define PIES_COMP_DEFAULT 0
-#define PIES_COMP_WAIT 0x01
-#define PIES_COMP_MASK(m) (1 << ((m)+1))
+#define PIES_COMP_MASK(m) (1 << ((m)))
@@ -319,2 +318,8 @@ void free_action (struct action *act);
+#define PIES_CHLD_NONE 0
+#define PIES_CHLD_CLEANUP 0x01
+#define PIES_CHLD_WAKEUP 0x02
+
+void pies_schedule_children (int op);
+
void register_prog (struct component *comp);
@@ -514,3 +519,3 @@ int inittab_parse (const char *file);
int sysvinit_sigtrans (int sig, int *pact);
-void sysvinit_runlevel_setup (int mask, int *wait);
+void sysvinit_runlevel_setup (int mask);
void sysvinit_sysdep_begin (void);
diff --git a/src/prog.h b/src/prog.h
index 1db2eee..4658518 100644
--- a/src/prog.h
+++ b/src/prog.h
@@ -83,2 +83,4 @@ struct prog
#define IS_COMPONENT(p) ((p)->type == TYPE_COMPONENT)
+#define IS_ACTIVE_COMPONENT(prog) \
+ (IS_COMPONENT(prog) && !((prog)->v.p.comp->flags & CF_DISABLED))
diff --git a/src/progman.c b/src/progman.c
index 29b5331..8a5187c 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -1052,3 +1052,2 @@ prog_start (struct prog *prog)
}
- prog->v.p.wait = is_comp_wait (prog->v.p.comp);
}
@@ -1543,10 +1542,16 @@ progman_wake_sleeping (int onalrm)
- if (progman_waiting_p ())
- /* Noting to do if there are processes left in the previous runlevel */
- return;
+ debug (1, (_("checking for components to start")));
- debug (1, (_("managing sleeping/stopping components")));
+ for (prog = proghead; prog; prog = prog->next)
+ {
+ if (IS_ACTIVE_COMPONENT (prog) && prog->v.p.wait)
+ {
+ if (prog->v.p.status != status_running)
+ prog_start (prog);
+ return;
+ }
+ }
for (prog = proghead; prog; prog = prog->next)
- if (IS_COMPONENT (prog))
+ if (IS_ACTIVE_COMPONENT (prog))
{
@@ -2258,3 +2263,2 @@ react (struct prog *prog, int status, pid_t pid)
-
void
@@ -2318,2 +2322,4 @@ progman_cleanup (int expect_term)
prog->v.p.status = status_finished;
+ if (prog->v.p.wait)
+ pies_schedule_children (PIES_CHLD_WAKEUP);
prog->v.p.wait = 0;
diff --git a/src/sysvinit.c b/src/sysvinit.c
index c9447ff..2d0671c 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -214,3 +214,2 @@ struct enstate
int mask;
- int wait;
};
@@ -251,2 +250,3 @@ enablecomp (struct prog *prog, void *data)
return s && (s->mask & PIES_COMP_MASK (comp->mode));
+
default:
@@ -256,2 +256,5 @@ enablecomp (struct prog *prog, void *data)
+ if (!comp->runlevels)
+ return -1;
+
if (!strchr (comp->runlevels, runlevel))
@@ -262,12 +265,2 @@ enablecomp (struct prog *prog, void *data)
- if (s && s->mask & PIES_COMP_WAIT)
- {
- if (comp->mode == pies_comp_wait)
- {
- s->wait = 1;
- return 1;
- }
- return 0;
- }
-
return 1;
@@ -287,5 +280,8 @@ runlevel_setup_prog (struct prog *prog, void *data)
prog->v.p.comp->flags |= CF_DISABLED;
- debug (2, ("%s: %s", prog_tag (prog),
+ prog->v.p.wait = is_comp_wait (prog->v.p.comp);
+ debug (2, ("%s: %s%s", prog_tag (prog),
prog->v.p.comp->flags & CF_DISABLED ?
- "disabled" : "enabled"));
+ "disabled" : "enabled",
+ !(prog->v.p.comp->flags & CF_DISABLED) && prog->v.p.wait
+ ? " (wait)" : ""));
}
@@ -295,3 +291,3 @@ runlevel_setup_prog (struct prog *prog, void *data)
void
-sysvinit_runlevel_setup (int mask, int *wait)
+sysvinit_runlevel_setup (int mask)
{
@@ -299,10 +295,3 @@ sysvinit_runlevel_setup (int mask, int *wait)
s.mask = mask;
- if (wait)
- {
- s.mask |= PIES_COMP_WAIT;
- s.wait = *wait;
- }
progman_foreach (runlevel_setup_prog, &s);
- if (wait)
- *wait = s.wait;
}
@@ -708,3 +697,3 @@ sysvinit_begin ()
envsetup ();
- sysvinit_runlevel_setup (PIES_COMP_DEFAULT, NULL);
+ sysvinit_runlevel_setup (PIES_COMP_DEFAULT);
add_extra_sigv (sigv, ARRAY_SIZE (sigv));
@@ -745,3 +734,2 @@ inittrans ()
int trans = 0;
- static int wait = 0;
@@ -765,3 +753,2 @@ inittrans ()
trans = 1;
- wait = 0;
}
@@ -781,4 +768,7 @@ inittrans ()
if (trans)
- /* boot -> normal */
- create_fifo ();
+ {
+ /* boot -> normal */
+ create_fifo ();
+ ctl_open ();
+ }
}
@@ -793,6 +783,4 @@ inittrans ()
trans = 1;
- wait = 0;
}
- if (wait)
- trans = 1;
+
if (trans)
@@ -802,9 +790,3 @@ inittrans ()
envsetup ();
- if (wait == 0)
- {
- sysvinit_runlevel_setup (PIES_COMP_DEFAULT, &wait);
- if (wait)
- return 1;
- }
- sysvinit_runlevel_setup (PIES_COMP_DEFAULT, NULL);
+ sysvinit_runlevel_setup (PIES_COMP_DEFAULT);
@@ -819,5 +801,2 @@ inittrans ()
}
-
- /* Clear the wait flag */
- wait = 0;
}
@@ -1149,3 +1128,3 @@ powerfailcmd (int power_stat)
- sysvinit_runlevel_setup (mask, NULL);
+ sysvinit_runlevel_setup (mask);
}

Return to:

Send suggestions and report system problems to the System administrator.