INIT(8)

NAME
init - process control initialization

SYNOPSIS
/etc/init

DESCRIPTION
Init is invoked by the kernel as the last step in the boot procedure. It is always process 1.

When started normally, init calls rc(8). The security label is set at bottom. If this succeeds, init begins multi-user operation. If rc fails, init commences single user operation by executing a superuser shell, nosh(8), with bottom security label, top ceiling, and all privileges.

When started by a cold boot from the console, init starts single user operation immediately. When the single user shell terminates, init runs rc without the parameter, and begins multi-user operation.

In multi-user operation, init's role is to create a process for each directly connected terminal port on which a user may log in. To begin such operations, it reads the ttys(5) file and forks to create a process for each terminal specified in the file. Each of these processes opens the appropriate terminal for reading and writing on file descriptors 0, 1, 2, and 3 (the standard input and output, the diagnostic output and The security label of each port is set to that of file Opening the terminal will usually involve a delay, since the open is not completed until someone dials and carrier is established on the channel. Then getty(8) is called with argument as specified by the second character of the ttys file line. Getty reads the user's name and invokes login(8) to log in the user and execute the shell.

Ultimately the shell will terminate because of an end-of-file or 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(5), which records current users, and makes an entry in wtmp, which maintains a history of logins and logouts. Then the appropriate terminal is reopened and getty is invoked again.

Init catches signal SIGHUP and interprets it to mean that the ttys file should be read again. The shell process on each line that has become inactive according to ttys is terminated; a new process is created for each line added; lines unchanged in the file are undisturbed. Thus it is possible to drop or add terminal lines without rebooting the system by changing the ttys file and sending a hangup signal to the init process: use

Init will terminate multi-user operations, kill all outstanding processes, and resume single-user mode if sent signal SIGTERM: use Init will wait at most 30 seconds for outstanding processes to die, to avoid waiting forever.

If, at bootstrap time, the init program cannot be executed, the system will loop in user mode at a low address.

FILES

SEE ALSO
login(8), kill(1), sh(1), ttys(5), getty(8), rc(8), reboot(8)

BUGS
The single-user shell has all privileges.