INIT(8) UNIX Programmer's Manual INIT(8) NAME init - process control initialization SYNOPSIS /etc/init DESCRIPTION _I_n_i_t is invoked inside UNIX as the last step in the boot procedure. If this is a boot from software (automatic or from _r_e_b_o_o_t(8), it normally then runs the automatic reboot sequence as described in _r_e_b_o_o_t(8)), and if this succeeds, begins multi-user operation. If the reboot fails, it com- mences ``special session'' operation on a limited number of terminals (see below). It is possible to pass parameters from the boot program to _i_n_i_t so that single user operation is commenced immediately. When such single user operation is terminated by killing the single-user shell (i.e. by hit- ting ^D), _i_n_i_t runs /_e_t_c/_r_c without the reboot parameter. This command file performs housekeeping operations such as removing temporary files, mounting file systems, and start- ing daemons. In multi-user operation, _i_n_i_t'_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 /_e_t_c/_t_t_y_s and forks several times to create a process for each terminal speci- fied in the file. Each of these processes opens the appropriate terminal for reading and writing. These chan- nels thus receive file descriptors 0, 1 and 2, the standard input and output and the diagnostic output. Opening the terminal will usually involve a delay, since the _o_p_e_n is not completed until someone is dialed up and carrier established on the channel. If a terminal exists but an error occurs when trying to open the terminal _i_n_i_t complains by writing a message to the system console; the message is repeated every 10 minutes for each such terminal until the terminal is shut off in /_e_t_c/_t_t_y_s and init notified (by a hangup, as described below), or the terminal becomes accessible (init checks again every minute). After an open succeeds, /_e_t_c/_g_e_t_t_y is called with argument as specified by the second character of the _t_t_y_s file line. _G_e_t_t_y reads the user's name and invokes _l_o_g_i_n 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 _i_n_i_t, which has been waiting for such an event, wakes up and removes the appropriate entry from the file _u_t_m_p, which records current users, and makes an entry in /_u_s_r/_a_d_m/_w_t_m_p, which maintains a history of logins and logouts. The _w_t_m_p entry is made only if a user logged in successfully on the line. Then the Printed 8/2/83 1 INIT(8) UNIX Programmer's Manual INIT(8) appropriate terminal is reopened and _g_e_t_t_y is reinvoked. _I_n_i_t catches the _h_a_n_g_u_p signal (signal SIGHUP) and inter- prets it to mean that the file /_e_t_c/_t_t_y_s should be read again. The Shell process on each line which used to be active in _t_t_y_s 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 phone lines without rebooting the system by changing the _t_t_y_s file and sending a _h_a_n_g_u_p signal to the _i_n_i_t process: use `kill -HUP 1.' _I_n_i_t 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), _i_n_i_t will not wait for them all to die (which might take for- ever), but will time out after 30 seconds and print a warn- ing message. _I_n_i_t will cease creating new _g_e_t_t_y's and allow the system to slowly die away, if it is sent a quit signal (QUIT) signal, i.e. ``kill -QUIT 1''. A later hangup will resume full multi-user operations, or a terminate will initiate a single user shell. This hook is used by _r_e_b_o_o_t(8). ``Special session'' is similar to multi-user operation, except that only root may log in, and a only a subset of the normal lines are used (those with `2' or `3' in the first position of their entries in /_e_t_c/_t_t_y_s). _I_n_i_t enters this mode if an automatic file system check fails at boot time, allowing the necessary file system repairs to be made. When _i_n_i_t then receives an interrupt signal (INT), it shuts down, runs /_e_t_c/_r_c, then comes up for normal multi-user opera- tions. An interrupt signal from multi-user mode shuts down the system, then begins special session. _I_n_i_t'_s role is so critical that if it dies, the system will reboot itself automatically. If, at bootstrap time, the _i_n_i_t process cannot be located, the system will print a mes- sage and loop in user mode at location 06. DIAGNOSTICS Diagnostic messages from _i_n_i_t are printed on the system con- sole. init: _t_t_y: cannot open. A terminal which is turned on in the _t_t_y_s file cannot be opened, likely because the requisite lines are either not configured into the system or the asso- ciated special files in /dev do not exist. Printed 8/2/83 2 INIT(8) UNIX Programmer's Manual INIT(8) WARNING: Something is hung (won't 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 for diagnostic messages /dev/tty?? /etc/utmp /usr/adm/wtmp /etc/ttys /etc/rc script run when going multiuser SEE ALSO kill(1), login(1), sh(1), ttys(5), crash(8), getty(8), rc(8), reboot(8), shutdown(8) Printed 8/2/83 3