aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/progman.c')
-rw-r--r--src/progman.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/progman.c b/src/progman.c
index 3bbd8b3..4ca3824 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -114,16 +114,6 @@ progman_lookup_tcpmux (const char *service, const char *master)
return NULL;
}
-struct prog *
-prog_lookup_by_idx (unsigned idx)
-{
- struct prog *prog;
- for (prog = proghead; prog; prog = prog->next)
- if (IS_COMPONENT (prog) && prog->v.p.idx == idx)
- break;
- return prog;
-}
-
void prog_stop (struct prog *prog, int sig);
static int prog_start_prerequisites (struct prog *prog);
@@ -305,15 +295,19 @@ register_command (char *tag, char *command, pid_t pid)
}
int
-progman_running_p ()
+progman_waiting_p ()
{
struct prog *prog;
for (prog = proghead; prog; prog = prog->next)
{
- if (IS_COMPONENT (prog) && is_comp_wait (prog->v.p.comp) &&
- prog->pid > 0)
- return 1;
+ if (IS_COMPONENT (prog) && prog->v.p.wait && prog->pid > 0)
+ {
+ debug(1, ("%s: waiting for %s (%lu)",
+ __FUNCTION__, prog_tag (prog),
+ (unsigned long) prog->pid));
+ return 1;
+ }
}
return 0;
}
@@ -1059,6 +1053,7 @@ prog_start (struct prog *prog)
}
return;
}
+ prog->v.p.wait = is_comp_wait (prog->v.p.comp);
debug (1, ("ok to start %s", prog->v.p.comp->tag));
}
@@ -1501,6 +1496,10 @@ progman_start ()
{
struct prog *prog;
+ if (progman_waiting_p ())
+ /* Noting to do if there are processes left in the previous runlevel */
+ return;
+
recompute_alarm = 0;
debug (1, ("starting components"));
for (prog = proghead; prog; prog = prog->next)
@@ -1546,6 +1545,10 @@ progman_wake_sleeping (int onalrm)
struct prog *prog;
time_t now = time (NULL);
+ if (progman_waiting_p ())
+ /* Noting to do if there are processes left in the previous runlevel */
+ return;
+
debug (1, (_("managing sleeping/stopping components")));
for (prog = proghead; prog; prog = prog->next)
@@ -2254,6 +2257,9 @@ progman_cleanup (int expect_term)
{
pid_t pid;
int status;
+
+ if (!expect_term)
+ expect_term = progman_waiting_p ();
while ((pid = waitpid (-1, &status, WNOHANG)) > 0)
{
struct prog *prog = prog_lookup_by_pid (pid);
@@ -2304,6 +2310,7 @@ progman_cleanup (int expect_term)
sysvinit_acct (SYSV_ACCT_PROC_STOP, "", prog_tag (prog),
pid, "");
prog->v.p.status = status_finished;
+ prog->v.p.wait = 0;
}
else
{

Return to:

Send suggestions and report system problems to the System administrator.