SysIII/usr/src/man/man8/init.8

.TH INIT 8
.SH NAME
init \- process control initialization
.SH SYNOPSIS
.B /etc/init
[ state ]
.SH DESCRIPTION
.I Init\^
is invoked inside
.SM UNIX
as the last step in the boot procedure.
It is process number one, and is the ancestor of every other process
in the system.
As such, it can be used to control the process structure of the system.
If
.I init\^
is invoked with an argument by the super-user,
it will cause a change in state of
process one.
.PP
.I Init\^
has 9 states, 1 through 9;
it is invoked by the system in state 1, and it
performs the same functions on entering each state.
When a state is entered,
.I init\^
reads the file
.BR /etc/inittab .
Lines in this file have the format:
.PP
.RS
state:id:flags:command
.RE
.PP
All lines in which the state field matches
.IR init 's
current state are recognized.
If a process is active under the same two character
.I id\^
as a recognized line, it may be terminated (signal 15), killed
(signal 9), or both by including the
.I flags\^
.B t
and
.B k
in the order desired.
The signal is sent to all processes in the process group associated
with the
.IR id .
The
.I command\^
field is saved for later execution.
.PP
After reading
.B /etc/inittab
and signaling running processes as required,
but before invoking any processes under the new state,
.B /etc/rc
is invoked with three arguments.
This command file
performs housekeeping
such as removing temporary files,
mounting file systems, and starting
daemons.
The three arguments are the current state, the number of
times this state has been entered previously, and the prior state.
.I Init\^
will also execute
.B /etc/rc
at the request of the operating system
(e.g., when recovering from power failure).
In this last case, the first argument
has an
.B x
appended to it.
.PP
When
.B /etc/rc
has finished executing,
.I init\^
invokes all
.I commands\^
waiting to be executed.
(A
.I command\^
is waiting to be executed if there is no process currently
running that has the same
.I id\^
as the command.)
The
.I flag\^
.B c
(continuous)
requires the
.I command\^
to be continuously reinvoked whenever the process with that
.I id\^
dies.
The
.I flag\^
.B o
(off)
causes the
.I command\^
to be ignored.
This is useful for turning lines off without extensive editing.
Otherwise, the
.I command\^
is invoked a maximum of one time in the current state.
.PP
.I Init\^
invokes the
.I command\^
field read from
.B /etc/inittab
by opening
.B /
for reading and writing on file descriptors 0, 1, and 2,
resetting all signals to system default,
setting up a new process group
.RI ( setpgrp (2)),
and
.IR exec ing:
.PP
.RS
/bin/sh \|\-c \|exec\|
.I command\^
.RE
.SH DIAGNOSTICS
When
.I init\^
can do nothing else because of a missing
.B /etc/inittab
or when it has no children left,
it will try to execute a shell on
.BR /dev/console .
When the problem has been fixed, it is necessary to change states,
and terminate the shell.
.SH BUGS
.I Init\^
does not complain if the state\-id pairs in
.B /etc/inittab
are not unique.
For any given pair, the last one in the file is valid.
.SH FILES
/etc/inittab
.br
/etc/rc
.br
/bin/sh
.br
/dev/console
.SH "SEE ALSO"
login(1), sh(1), exec(2), setpgrp(2), inittab(5), getty(8).