INIT(8)

NAME
init, telinit - process control initialization

SYNOPSIS
/etc/init [ -t sec ] [ 0123456SsQq ]
/bin/telinit [ -t sec ] [ 0123456sSQqabc ]

DESCRIPTION

  Init
Init is the father of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab (see inittab(5)). This file usually has entries which cause init to spawn gettys on each line that users can log in. It also controls autonomous processes required by any particular system.

A run level is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init for each of these run levels are defined in the /etc/inittab file. Init can be in one of eight run levels, 0–6 and S or s. The run level is changed by having a privileged user run /bin/telinit, which sends appropriate signals to init, telling it which run level to change to.

After init is invoked as the last step of the kernel booting, it looks for the file /etc/inittab to see if there is an entry of the type initdefault (see inittab(5)). initdefault determines the initial run level of the system. If there is no such entry or no /etc/inittab at all, a run level has to be entered at the system console.

Run level S or s bring the system to single user mode and do not require an /etc/initttab file. In single user mode, /bin/su is invoked on /dev/console.

When entering single user mode, init saves the console ioctl(2) state to /etc/ioctl.save and resets the console to these states when exiting to multi user mode. If this file does not exist then default settings are used.

When entering a multi user mode the first time, init performs the boot and bootwait entries to allow file systems to be mounted before users can log in. Then all entries matching the run level are processed.

Each time a child terminates, init records the fact and the reason it died in /etc/utmp and /usr/adm/wtmp if these files exist.

After it has spawned all of the processes specified, init waits for one of its descendant processes to die, a powerfail signal, or until it is signaled by /bin/telinit to change the system's run level. When one of the above three conditions occurs, it re-examines the /etc/inittab. file. New entries can be added to this file at any time. However, init still waits for one of the above three conditions to occur. To provide for an instantaneous response, the Q or q command can wake up init to re-examine the /etc/inittab file.

If init is not in single user mode and receives a powerfail signal, special powerfail entries are invoked.

When init is requested to change the run level, it sends the warning signal SIGTERM to all processes that are undefined in the new run level. It then waits 20 seconds before forcibly terminating these processes via the kill signal SIGKILL. Note that init assumes that all these processes (and their descendants) remain in the same process group which init originally created for them. If any process changes its process group affiliation it will not receive these signals. Such processes need to be terminated separately.

  telinit
/bin/telinit is linked to /etc/init. It takes a one-character argument and signals init to perform the appropriate action. The following arguments serve as directives to /bin/telinit:

0,1,2,3,4,5 or 6
    tell /etc/init to switch to the specified run level.

a,b,c
    tell /etc/init to process only those /etc/inittab file entries having run level a,b or c.

Q or q
    tells /etc/init to re-examine the /etc/inittab file.

S or s
    tells /etc/init to switch to single user mode.

/bin/telinit can also tell init how much time it should wait between sending processes the TERM and the KILL signal; default this is 20 seconds, but it can be changed by the -t sec option.

/bin/telinit can be invoked only by users with appropriate privileges.

FILES
/etc/inittab
/dev/console
/etc/utmp
/usr/adm/wtmp

CONFORMING TO
Init is not really System V compatible. It is more modeled after the HP-UX init. This might change in the future if people feel that is really needed.

WARNINGS
Init assumes that processes and descendants of processes remain in the same process group which was originally created for them. If the processes change their group, init can't kill them and you may end up with two processes reading from one terminal line.

DIAGNOSTICS
If /etc/init finds that it is continuously respawning an entry more than 10 times in 2 minutes, it will assume that there is an error in the command string, generate an error message on the system console, and refuse to respawn this entry until either 5 minutes has elapsed or it receives a signal. This prevents it from eating up system resources when someone makes a typographical error in the /etc/inittab file or the program for the entry is removed.

RESTRICTIONS
If init or telinit is used to go into single user mode, the terminal from which this command was given should become the new logical system console. This is not implemented. Also, Init should save the modes of the system console every time single user mode is entered in the file /etc/ioctl.save, and restore them when single user mode is left. This is also not implemented.

AUTHOR
Miquel van Smoorenburg (miquels@drinkel.nl.mugnet.org), initial manual page by Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de).

SEE ALSO
getty(1), login(1), sh(1), who(1), kill(2), inittab(5), utmp(5).