summaryrefslogtreecommitdiffabout
path: root/src/progman.c
Side-by-side diff
Diffstat (limited to 'src/progman.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/progman.c74
1 files changed, 58 insertions, 16 deletions
diff --git a/src/progman.c b/src/progman.c
index a625885..bae82ba 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -287,7 +287,9 @@ register_prog0 (struct component *comp)
else
newp->v.p.status = status_stopped;
- if ((comp->flags & CF_DISABLED) || comp->mode == pies_comp_ondemand)
+ if ((comp->flags & CF_DISABLED)
+ || comp->mode == pies_comp_ondemand
+ || comp->mode == pies_comp_shutdown)
newp->active = 0;
else
newp->active = 1;
@@ -1795,21 +1797,6 @@ prog_stop (struct prog *prog, int sig)
kill (prog->pid, sig);
}
-static int
-mark_for_stopping (struct prog *prog, void *data)
-{
- if (IS_COMPONENT (prog))
- prog->stop = 1;
- return 0;
-}
-
-void
-progman_stop (void)
-{
- progman_foreach (mark_for_stopping, NULL);
- progman_gc ();
-}
-
static void
print_status (const char *tag, pid_t pid, int status, int expect_term)
{
@@ -2582,4 +2569,59 @@ progman_gc (void)
}
+static int
+start_shutdown (struct prog *prog, void *data)
+{
+ if (IS_COMPONENT (prog) && prog->v.p.comp->mode == pies_comp_shutdown)
+ {
+ int *p = data;
+ if (!*p)
+ {
+ diagmsg (DIAG_CON, LOG_INFO, "Starting shutdown components");
+ *p = 1;
+ }
+ prog->active = 1;
+ prog_start (prog);
+ prog->stop = 1;
+ }
+ return 0;
+}
+
+void
+program_shutdown (void)
+{
+ time_t start = time (NULL);
+ int sd = 0;
+
+ /* Activate shutdown components. */
+ progman_foreach (start_shutdown, &sd);
+ while (prog_to_stop (proghead))
+ {
+ progman_cleanup (1);
+ if (time (NULL) - start < shutdown_timeout)
+ sleep (1);
+ else
+ {
+ progman_gc ();
+ break;
+ }
+ }
+}
+
+static int
+mark_for_stopping (struct prog *prog, void *data)
+{
+ if (IS_COMPONENT (prog))
+ prog->stop = 1;
+ return 0;
+}
+
+void
+progman_stop (void)
+{
+ progman_foreach (mark_for_stopping, NULL);
+ progman_gc ();
+ program_shutdown ();
+}
+
/* EOF */

Return to:

Send suggestions and report system problems to the System administrator.