diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-02-17 08:26:42 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-02-17 08:30:12 +0200 |
commit | e430f586ccf6621136089fb1d9d865ce1a351360 (patch) | |
tree | af09d48b994a55752f210b29cb73f147e5b7f728 /src | |
parent | bd8bd1640c72ceefd87b46a7a3d378c78c9081f5 (diff) | |
download | pies-e430f586ccf6621136089fb1d9d865ce1a351360.tar.gz pies-e430f586ccf6621136089fb1d9d865ce1a351360.tar.bz2 |
Fix state transitions
* src/pies.c (main): Move call to pies_schedule_children
to inittrans.
* src/progman.c (progman_cleanup): Minor change.
* src/sysvinit.c (enablecomp): Change prog status
to stopped when leaving its runlevel.
(sysvinit_set_runlevel): Raise SIGALRM instead of calling
inittrans directly.
(inittrans): Fix wait logic.
Diffstat (limited to 'src')
-rw-r--r-- | src/pies.c | 5 | ||||
-rw-r--r-- | src/progman.c | 7 | ||||
-rw-r--r-- | src/sysvinit.c | 20 |
3 files changed, 19 insertions, 13 deletions
@@ -2171,10 +2171,7 @@ main (int argc, char **argv) do { if (init_process && inittrans ()) - { - pies_schedule_children (PIES_CHLD_WAKEUP); - action = ACTION_CONT; - } + action = ACTION_CONT; else if (children_op == PIES_CHLD_NONE) pies_pause (); switch (action) diff --git a/src/progman.c b/src/progman.c index d6929d6..9641629 100644 --- a/src/progman.c +++ b/src/progman.c @@ -2331,9 +2331,12 @@ progman_cleanup (int expect_term) sysvinit_acct (SYSV_ACCT_PROC_STOP, "", prog_tag (prog), pid, ""); prog->v.p.status = status_finished; + if (prog->v.p.wait) - pies_schedule_children (PIES_CHLD_WAKEUP); - prog->v.p.wait = 0; + { + pies_schedule_children (PIES_CHLD_WAKEUP); + prog->v.p.wait = 0; + } } else { diff --git a/src/sysvinit.c b/src/sysvinit.c index 625fd7b..7fad00b 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c @@ -250,7 +250,7 @@ enablecomp (struct prog *prog, void *data) case pies_comp_powerfailnow: case pies_comp_kbrequest: return s && (s->mask & PIES_COMP_MASK (comp->mode)); - + default: break; } @@ -260,7 +260,11 @@ enablecomp (struct prog *prog, void *data) return -1; if (!strchr (comp->runlevels, runlevel)) - return 0; + { + if (prog->v.p.status == status_finished && comp->mode != pies_comp_once) + prog->v.p.status = status_stopped; + return 0; + } if (prog->v.p.status == status_finished) return -1; @@ -438,7 +442,7 @@ sysvinit_set_runlevel (int newlevel) else { dfl_level = newlevel; - inittrans (); + raise (SIGALRM); } } return 0; @@ -765,9 +769,9 @@ cond_running_disabled (struct prog *prog, void *data) } static int -running_disabled (void *data) +no_disabled_running (void *data) { - return progman_foreach (cond_running_disabled, NULL); + return !progman_foreach (cond_running_disabled, NULL); } static int @@ -846,12 +850,14 @@ inittrans () /* Stop disabled programs */ sig = SIGTERM; progman_foreach (terminate_disabled, &sig); - if (progman_wait_until (running_disabled, NULL)) + if (progman_wait_until (no_disabled_running, NULL)) { sig = SIGKILL; progman_foreach (terminate_disabled, &sig); - progman_wait_until (running_disabled, NULL); + progman_wait_until (no_disabled_running, NULL); } + + pies_schedule_children (PIES_CHLD_WAKEUP); } return trans; } |