path: root/src/comp.c
authorSergey Poznyakoff <>2016-02-12 12:25:26 (GMT)
committer Sergey Poznyakoff <>2016-02-12 12:25:26 (GMT)
commit05f16374d677f7c606d5100df3ca3499b9891aca (patch) (side-by-side diff)
treeefa6177f87df2ba1e9f63edec6cc55cb621c9745 /src/comp.c
parentd9d267052215f223897af18310e4adee310308e7 (diff)
Improve progman API (progman_foreach and progman_stop_component).
* src/progman.c (progman_foreach): Allow filter to remove its prog argument from the list. Return integer (result of the call to filter, that returned non-zero). All uses changed. (progman_running_count): Remove. (progman_stop_component): Take a pointer to pointer. Pass it to destroy_prog when needed. All uses changed. * src/comp.c (prog_is_leftover): New function. (cb_terminate_prog): Use prog_is_leftover. Don't raise CF_DISABLED flag, as prog will have been destroyed by progman_stop_component. (cb_kill_prog): Use prog_is_leftover. * src/ctl.c (fun_stop): Check if prog still exists after the call to progman_stop_component. * src/pies.h (progman_running_count): Removed. * src/prog.h (progman_foreach): Return int. (progman_stop_component): Change signature.
Diffstat (limited to 'src/comp.c') (more/less context) (show whitespace changes)
1 files changed, 12 insertions, 6 deletions
diff --git a/src/comp.c b/src/comp.c
index 5613e28..6a0e4ba 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -351,21 +351,27 @@ component_config_rollback (void)
cur = prev_index ();
+/* Return true if PROG is a leftover from previous configuration */
static int
-cb_terminate_prog (struct prog *prog, void *data)
- if (IS_COMPONENT (prog) && !component_is_active (prog->v.p.comp))
+prog_is_leftover (struct prog *prog)
- progman_stop_component (prog);
- prog->v.p.comp->flags |= CF_DISABLED;
+ return IS_COMPONENT (prog) && !component_is_active (prog->v.p.comp);
+/* If PROG is a leftover, gracefully stop it and mark as disabled */
+static int
+cb_terminate_prog (struct prog *prog, void *data)
+ if (prog_is_leftover (prog))
+ progman_stop_component (&prog);
return 0;
+/* If PROG is a leftover, slay it with SIGKILL */
static int
cb_kill_prog (struct prog *prog, void *data)
- if (!(IS_COMPONENT (prog) && component_is_active (prog->v.p.comp)))
+ if (prog_is_leftover (prog))
prog_stop (prog, SIGKILL);
return 0;

Return to:

Send suggestions and report system problems to the System administrator.