INIT(8) — UNIX 3.0
NAME
init − process control initialization
SYNOPSIS
/etc/init [ state ]
DESCRIPTION
Init is invoked inside 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 init is invoked with an argument by the super-user, it will cause a change in state of process one.
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, init reads the file /etc/inittab. Lines in this file have the format:
state:id:flags:command
All lines in which the state field matches init’s current state are recognized. If a process is active under the same two character id as a recognized line, it may be terminated (signal 15), killed (signal 9), or both by including the flags t and k in the order desired. The signal is sent to all processes in the process group associated with the id. The command field is saved for later execution.
After reading /etc/inittab and signaling running processes as required, but before invoking any processes under the new state, /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. Init will also execute /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 x appended to it.
When /etc/rc has finished executing, init invokes all commands waiting to be executed. (A command is waiting to be executed if there is no process currently running that has the same id as the command.) The flag c (continuous) requires the command to be continuously reinvoked whenever the process with that id dies. The flag o (off) causes the command to be ignored. This is useful for turning lines off without extensive editing. Otherwise, the command is invoked a maximum of one time in the current state.
Init invokes the command field read from /etc/inittab by opening / for reading and writing on file descriptors 0, 1, and 2, resetting all signals to system default, setting up a new process group (setpgrp(2)), and execing:
/bin/sh −c exec command
DIAGNOSTICS
When init can do nothing else because of a missing /etc/inittab or when it has no children left, it will try to execute a shell on /dev/console. When the problem has been fixed, it is necessary to change states, and terminate the shell.
BUGS
Init does not complain if the state−id pairs in /etc/inittab are not unique. For any given pair, the last one in the file is valid.
FILES
/etc/inittab
/etc/rc
/bin/sh
/dev/console
SEE ALSO
login(1), sh(1), exec(2), setpgrp(2), inittab(5), getty(8).
May 16, 1980