BSD 4_2 development
[unix-history] / usr / man / man8 / init.8
CommitLineData
3d05fdff
C
1.TH INIT 8 "1 April 1981"
2.UC 4
3.SH NAME
4init \- process control initialization
5.SH SYNOPSIS
6.B /etc/init
7.SH DESCRIPTION
8.I Init
9is invoked inside UNIX as the last step in the boot procedure.
10It normally then runs the automatic reboot sequence as described in
11.IR reboot (8),
12and if this succeeds, begins multi-user operation.
13If the reboot fails, it commences single user operation by giving
14the super-user a shell on the console. It is possible to pass parameters
15from the boot program to
16.I init
17so that single user operation is commenced immediately.
18When such single user operation is terminated by killing the single-user
19shell (i.e. by hitting ^D),
20.I init
21runs
22.I /etc/rc
23without the reboot parameter.
24This command file
25performs housekeeping operations
26such as removing temporary files,
27mounting file systems, and starting
28daemons.
29.PP
30In multi-user operation,
31.I init's
32role is to create a process for each
33terminal port on which a user may log in.
34To begin such operations, it reads the file
35.I /etc/ttys
36and
37forks several times to create a process
38for each terminal specified in the file.
39Each of these processes opens the appropriate terminal
40for reading and writing. These channels thus
41receive file descriptors 0, 1 and 2, the standard input and
42output and the diagnostic output.
43Opening the terminal will usually involve a delay,
44since the
45.IR open ""
46is not completed until someone
47is dialed up and carrier established on the channel.
48If a terminal exists but an error occurs when trying to open the terminal
49.I init
50complains by writing a message to the system console;
51the message is repeated every 10 minutes for each such terminal
52until the terminal is shut off in /etc/ttys and init notified (by
53a hangup, as described below), or the terminal becomes accessible
54(init checks again every minute).
55After an open succeeds,
56.I /etc/getty
57is called with argument as specified by the second character of
58the
59.I ttys
60file line.
61.I Getty
62reads the user's name and invokes
63.I login
64to log in the user and execute the Shell.
65.PP
66Ultimately the Shell will terminate
67because of an end-of-file either
68typed explicitly or generated as a result of hanging up.
69The main path of
70.IR init ,
71which has been waiting
72for such an event,
73wakes up and removes the appropriate entry from the
74file
75.IR utmp ,
76which records current users, and
77makes an entry in
78.IR /usr/adm/wtmp ,
79which maintains a history
80of logins and logouts.
81The
82.I wtmp
83entry is made only if a user logged in successfully on the line.
84Then the appropriate terminal is reopened and
85.I getty
86is
87reinvoked.
88.PP
89.I Init
90catches the
91.I hangup
92signal (signal SIGHUP) and interprets it to mean that
93the file
94.I /etc/ttys
95should be read again.
96The Shell process on each line which used to be active
97in
98.I ttys
99but is no longer there is terminated;
100a new process is created for each added line;
101lines unchanged in the file are undisturbed.
102Thus it is possible to drop or add phone lines without
103rebooting the system by changing the
104.I ttys
105file and sending a
106.I hangup
107signal to the
108.I init
109process: use `kill \-HUP 1.'
110.PP
111.I Init
112will terminate multi-user operations and resume single-user mode
113if sent a terminate (TERM) signal, i.e. ``kill \-TERM 1''.
114If there are processes outstanding which are deadlocked (due to
115hardware or software failure),
116.I init
117will not wait for them all to die (which might take forever), but
118will time out after 30 seconds and print a warning message.
119.PP
120.I Init
121will cease creating new
122.IR getty 's
123and allow the system to slowly die away, if it is sent a terminal stop (TSTP)
124signal, i.e. ``kill \-TSTP 1''. A later hangup will resume full
125multi-user operations, or a terminate will initiate a single user shell.
126This hook is used by
127.IR reboot (8)
128and
129.IR halt (8).
130.PP
131.I Init's
132role is so critical that if it dies, the system will reboot itself
133automatically.
134If, at bootstrap time, the
135.I init
136process cannot be located, the system will loop in user mode at location
1370x13.
138.SH DIAGNOSTICS
139\fBinit: \fR\fItty\fR\|\fB: cannot open\fR. A terminal which is turned
140on in the \fIrc\fR file cannot be opened, likely because the requisite
141lines are either not configured into the system or the associated device
142was not attached during boot-time system configuration.
143.LP
144\fBWARNING: Something is hung (wont die); ps axl advised\fR. A process
145is hung and could not be killed when the system was shutting down.
146This is usually caused by a process
147which is stuck in a device driver due to a persistent device error condition.
148.SH FILES
149/dev/console,
150/dev/tty*,
151/etc/utmp,
152/usr/adm/wtmp,
153/etc/ttys,
154/etc/rc
155.SH "SEE ALSO"
156login(1), kill(1), sh(1), ttys(5), crash(8V), getty(8), rc(8), reboot(8),
157halt(8), shutdown(8)