INIT(8) — UNIX Programmer’s Manual
NAME
init − process control initialization
SYNOPSIS
init
DESCRIPTION
Init is invoked inside the system as the last step in the boot procedure. Init commences single user operation by giving the super-user a shell on the console. It is possible to pass parameters from the boot program to init so that single user operation is commenced immediately.
When such single user operation is terminated by killing the single-user shell (i.e. by hitting Control-d), init runs /etc/rc. This command file performs housekeeping operations such as removing temporary files, mounting file systems, starting daemons, and the /etc/update process.
In multi-user operation, with the "" prompt, init’s role is to create a process for each terminal port on which a user may log in. To begin such operations, it reads the file /etc/ttys and forks several times to create a process for each terminal specified in the file. Each of these processes opens the appropriate terminal for reading and writing. These channels thus receive file descriptors 0, 1 and 2, the standard input and output and the diagnostic output.
If a terminal exists but an error occurs when trying to open the terminal init complains by writing a message to the system console. After an open succeeds, /etc/getty is called with argument as specified by the second character of the ttys file line. Getty reads the user’s name and invokes login to log in the user and execute the Shell. Usually, users will begin by running the C shell, but this can be changed by editing the password file (see passwd(5)).
Ultimately the Shell will terminate because of an end-of-file (Control-d) either typed explicitly or generated as a result of hanging up. The main path of init, which has been waiting for such an event, wakes up and removes the appropriate entry from the file utmp, which records current users, and makes an entry in /usr/adm/wtmp, which maintains a history of logins and logouts. Then the appropriate terminal is reopened and getty is reinvoked.
Init catches the hangup signal (signal SIGHUP) and interprets it to mean that the file /etc/ttys should be read again. The Shell process on each line which used to be active in ttys but is no longer there is terminated; a new process is created for each added line; lines unchanged in the file are undisturbed. Thus it is possible to drop or add lines without rebooting the system by changing the ttys file and sending a hangup signal to the init process: use ’kill -1 1’ or ’kill −HUP 1.’
Init will terminate multi-user operations and resume single-user mode if sent a terminate (TERM) signal, i.e. "kill −TERM 1". If there are processes outstanding which are deadlocked (due to hardware or software failure), init will not wait for them all to die (which might take forever), but will time out after 30 seconds and print a warning message.
If, at bootstrap time, the init process cannot be located, the system will loop in user mode.
DIAGNOSTICS
"init: tty: cannot open." A terminal which is turned on in the rc file cannot be opened, likely because the requisite lines are either not configured into the system or the associated device was not attached during boot-time system configuration.
WARNING: Something is hung (wont die); ps axl advised. A process is hung and could not be killed when the system was shutting down. This is usually caused by a process which is stuck in a device driver due to a persistent device error condition.
FILES
/dev/console
/dev/tty?
/etc/utmp
/usr/adm/wtmp
/etc/ttys
/etc/rc
SEE ALSO
login(1), kill(1), sh(1), ttys(5), getty(8)
7th Edition — 2/19/82