[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Init : someone could comment this ?



On Mon, 07.01.08 10:44, Enrico Scholz (enrico scholz informatik tu-chemnitz de) wrote:

> 
> Casey Dahlin <cjdahlin ncsu edu> writes:
> 
> >>> A shell which emulates POSIX process handling in-process and uses
> >>> direct builtin function calls for commands like sed [...] Pipes and
> >>> the like would also have to be emulated
> >>
> >> For what do you need 'sed' or pipes to start/stop a daemon?
> >>
> > It appears at least 13 times in our current init system.
> 
> I think, nobody doubts that current initsystem is the worst one of
> the major linux distributions.  By changing paradigm from forking to
> non-forking daemon you can avoid all the complicated 'stop' code;
> e.g. 'start' will be
> 
> | pid = fork();
> | if (pid==0) { /* ... */ execve(...); }
> 
> and 'stop' be
> 
> | kill(pid, SIGTERM); /* wait for timeout/sigchld */ kill(pid, SIGKILL);

This is not as simple as it might appear. Well behaving daemons don't
detach before initialization is complete. This fact is implicitly used
by SysV init to make sure that daemons which depend on each other
(like in "Avahi needs D-Bus") to start in order, one after the
other, but only after the predependencies have started up completely.

There have been several ideas how signalling of startup completion
could be handled in a better way. Some suggest that waiting for D-Bus
name to appear might be a good solution. Scott Remnant had the idea to
run "raise(SIGSTOP)" in the daemon after initialization
completed. Then, the parent process will be signalled via SIGCHLD and
as soon as it is it will kill(child, SIGCONT) and know that the next
daemon can be started. 

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]