init, rc - process control initialization
Init is invoked as the last step of the boot procedure (see boot(8)). Generally its role
is to create a process for each typewriter on which a user may log in.
When init first is executed the console typewriter /dev/console. is opened for reading
and writing and the shell is invoked immediately. This feature is used to bring up a sin-
gle-user system. If the shell terminates, init comes up multi-user and the process
described below is started.
When init comes up multiuser, it invokes a shell, with input taken from the file /etc/rc.
This command file performs housekeeping like removing temporary files, mounting file sys-
tems, and starting daemons.
Then init reads the file /etc/ttys and forks several times to create a process for each
typewriter specified in the file. Each of these processes opens the appropriate type-
writer for reading and writing. These channels thus receive file descriptors 0, 1 and 2,
the standard input, output and error files. Opening the typewriter will usually involve a
delay, since the open is not completed until someone is dialed up and carrier established
on the channel. Then /etc/getty is called with argument as specified by the last charac-
ter of the ttys file line. Getty reads the user's name and invokes login(1) to log in the
user and execute the shell.
Ultimately the shell will terminate because of an end-of-file 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 typewriter is reopened and getty is reinvoked.
Init catches the hangup signal SIGHUP and interprets it to mean that the system should be
brought from multi user to single user. Use `kill -1 1' to send the hangup signal.
/dev/tty?, /etc/utmp, /usr/adm/wtmp, /etc/ttys, /etc/rc
login(1), kill(1), sh(1), ttys(5), getty(8)