aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-01-04 14:22:24 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-01-04 14:22:24 +0200
commita9c18ad30ba6072ca460b2abc482374fb3c207b2 (patch)
treebd969853eaebe30e04fd8658d9ba323f6f6ff2ab /src/progman.c
parentcf14c349fad774e477a80d1c5e6572f21f17ced1 (diff)
downloadpies-a9c18ad30ba6072ca460b2abc482374fb3c207b2.tar.gz
pies-a9c18ad30ba6072ca460b2abc482374fb3c207b2.tar.bz2
Implement runlevel transitions.
* src/sysvinit.c: New file. * src/Makefile.am: Add new file. * src/pies.c (initdefault, dfl_level): Move to sysvinit.c (modetab): Add new modes. (inittrans): Move to sysvinit.c * src/pies.h (is_sysvinit): New macro. (dfl_level): New extern. (runlevel_match, inittrans, is_comp_wait): New protos. * src/progman.c (progman_running_p): Take into account only components. Use is_comp_wait to determine if the component should be waited for. (prog_start): Run sysvinit components only when started as init process. (runlevel_match): Move to sysvinit.c (prog_start_prerequisites): Return immediately if the component is disabled.
Diffstat (limited to 'src/progman.c')
-rw-r--r--src/progman.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/src/progman.c b/src/progman.c
index 639c22f..e25219a 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -409,8 +409,11 @@ progman_running_p ()
struct prog *prog;
for (prog = proghead; prog; prog = prog->next)
- if (prog->pid > 0)
- return 1;
+ {
+ if (IS_COMPONENT (prog) && is_comp_wait (prog->v.p.comp) &&
+ prog->pid > 0)
+ return 1;
+ }
return 0;
}
@@ -1181,6 +1184,14 @@ prog_start (struct prog *prog)
if (prog->pid > 0 || !IS_COMPONENT (prog))
return;
+
+ if (is_sysvinit (prog->v.p.comp->mode) && !init_process &&
+ prog->v.p.status != status_disabled)
+ {
+ logmsg (LOG_NOTICE, "disabling sysvinit component %s", prog->tag);
+ prog->v.p.status = status_disabled;
+ return;
+ }
/* This call returns 1 in two cases: Either prog is marked as disabled,
in which case there's nothing more to do, or one or more of its
@@ -1256,9 +1267,17 @@ prog_start (struct prog *prog)
prog_start_prologue (prog);
switch (prog->v.p.comp->mode)
{
- case pies_comp_pass_fd:
- case pies_comp_exec:
- case pies_comp_once:
+ case pies_comp_accept:
+ case pies_comp_inetd:
+ prog_sockenv (prog);
+
+ dup2 (prog->v.p.socket, 0);
+ dup2 (prog->v.p.socket, 1);
+ close (prog->v.p.socket);
+ prog->v.p.socket = -1;
+ break;
+
+ default:
if (init_process)
{
int fd = console_open (O_RDWR|O_NOCTTY);
@@ -1288,16 +1307,6 @@ prog_start (struct prog *prog)
}
}
break;
-
- case pies_comp_accept:
- case pies_comp_inetd:
- prog_sockenv (prog);
-
- dup2 (prog->v.p.socket, 0);
- dup2 (prog->v.p.socket, 1);
- close (prog->v.p.socket);
- prog->v.p.socket = -1;
- break;
}
if (!init_process)
@@ -1346,8 +1355,9 @@ prog_start (struct prog *prog)
{
disable_socket (prog->v.p.socket);
}
- else if (prog->v.p.comp->mode != pies_comp_exec &&
- prog->v.p.comp->mode != pies_comp_once)
+ else if (prog->v.p.comp->mode == pies_comp_accept ||
+ prog->v.p.comp->mode == pies_comp_inetd ||
+ prog->v.p.comp->mode == pies_comp_pass_fd)
close (prog->v.p.socket);
prog->pid = pid;
prog->v.p.status = status_enabled;
@@ -1760,14 +1770,6 @@ progman_recompute_alarm ()
-static int
-runlevel_match (struct prog *prog)
-{
- if (!initdefault || !prog->v.p.comp->runlevels)
- return 1;
- return !!strchr (prog->v.p.comp->runlevels, initdefault);
-}
-
void
progman_start ()
{
@@ -1781,7 +1783,7 @@ progman_start ()
if (prog->v.p.comp->mode == pies_comp_inetd)
{
if ((prog->v.p.comp->flags & CF_DISABLED)
- || !runlevel_match (prog))
+ || !runlevel_match (prog->v.p.comp))
disable_socket (prog->v.p.socket);
else
{
@@ -1790,7 +1792,7 @@ progman_start ()
}
}
else if ((prog->v.p.status == status_enabled && prog->pid == 0
- && runlevel_match (prog))
+ && runlevel_match (prog->v.p.comp))
|| prog->v.p.status == status_sleeping)
prog_start (prog);
}
@@ -1872,6 +1874,8 @@ prog_start_prerequisites (struct prog *prog)
int i;
int ret;
+ if (prog->v.p.status == status_disabled)
+ return 1;
if (!prog->prereq)
return 0; /* Ok to startup */
debug (1, ("starting prerequisites of %s", prog->tag));

Return to:

Send suggestions and report system problems to the System administrator.