% "@(#)sag:$Id$"        
%--------------------------------------------------------------------
\chapter{Demons}
\label{chap:daemons}
%--------------------------------------------------------------------

	This section describes a number of background processes that
	provide some important services to the system.  The most important
	one is \cmd{init}, which is the mother of all processes.

\section{Init---numero uno} \label{sec:init}

	\meta general description of init and its responsibilities

	\meta alway process number 1

\section{Sysvinit}
\subsection{Features}
\subsection{\fn{/etc/inittab}}
\subsection{Startup scripts: \fn{/etc/rc*}}
\subsection{Shutdown}

\section{Demons}

\subsection{Black magic?}

	A \defin{demon} or \defin{daemon} is a program running in the
	background, invisibly to users, that provides the system with
	some sort of useful service.  From {\it The Jargon File\/}
	(also published as a book under the name {\it The New Hacker's
	Dictionary\/}):
%%%%%%%%
	\begin{quote} \defin{daemon} {\sl /day'mn/\/} or {\sl
	/dee'mn/\/} [from the mythological meaning, later rationalized
	as the acronym `Disk And Execution MONitor'] n.~A program that
	is not invoked explicitly, but lies dormant waiting for some
	condition(s) to occur.  The idea is that the perpetrator of
	the condition need not be aware that a daemon is lurking
	(though often a program will commit an action only because it
	knows that it will implicitly invoke a daemon).  For example,
	under \defin{ITS} writing a file on the \defin{LPT} spooler's
	directory would invoke the spooling daemon, which would then
	print the file.  The advantage is that programs wanting (in
	this example) files printed need neither compete for access to
	nor understand any idiosyncrasies of the \defin{LPT}.  They
	simply enter their implicit requests and let the daemon decide
	what to do with them.  Daemons are usually spawned
	automatically by the system, and may either live forever or be
	regenerated at intervals.

	Daemon and \defin{demon} are often used interchangeably, but
	seem to have distinct connotations.  The term `daemon' was
	introduced to computing by \defin{CTSS} people (who pronounced
	it {\sl /dee'mon/\/}) and used it to refer to what ITS called
	a \defin{dragon}.  Although the meaning and the pronunciation
	have drifted, we think this glossary reflects current (1993)
	usage.
	\end{quote}
%%%%%%%%
	\begin{quote} \defin{demon} n.~1.~[MIT] A portion of a program
	that is not invoked explicitly, but that lies dormant waiting
	for some condition(s) to occur.  See \defin{daemon}.  The
	distinction is that demons are usually processes within a
	program, while daemons are usually programs running on an
	operating system.  2. [outside MIT] Often used equivalently to
	\defin{daemon} --- especially in the \defin{UNIX} world, where the
	latter spelling and pronunciation is considered mildly
	archaic.

	Demons in sense 1 are particularly common in AI programs.  For
	example, a knowledge-manipulation program might implement inference
	rules as demons.  Whenever a new piece of knowledge was added,
	various demons would activate (which demons depends on the
	particular piece of data) and would create additional pieces of
	knowledge by applying their respective inference rules to the
	original piece.  These new pieces could in turn activate more
	demons as the inferences filtered down through chains of logic.
	Meanwhile, the main program could continue with whatever its
	primary task was.
	\end{quote}
%%%%%%%%
	The most basic background process, but an important one, is
	\cmd{/etc/update}, which does a \cmd{sync(2)} every
	30~seconds, thus forcing updates to be written to the disk
	every now and then.

	Other important demons are \cmd{crond} and \cmd{syslogd}.
	See their man pages for more information.

	\meta should give more examples: init

\subsection{Update and \cmd{bdflush}}

\subsection{Networking daemons}

\subsection{Printer queues---\cmd{lpd}}

\subsection{Periodic command execution---\cmd{crond}}

\subsection{Message logging---\cmd{syslogd}}
