78ed81a3 |
1 | .\" Copyright (c) 1993 Christoph M. Robitschko |
2 | .\" All rights reserved. |
3 | .\" |
4 | .\" Redistribution and use in source and binary forms, with or without |
5 | .\" modification, are permitted provided that the following conditions |
6 | .\" are met: |
7 | .\" 1. Redistributions of source code must retain the above copyright |
8 | .\" notice, this list of conditions and the following disclaimer. |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright |
10 | .\" notice, this list of conditions and the following disclaimer in the |
11 | .\" documentation and/or other materials provided with the distribution. |
12 | .\" 3. All advertising materials mentioning features or use of this software |
13 | .\" must display the following acknowledgement: |
14 | .\" This product includes software developed by Christoph M. Robitschko |
15 | .\" 4. The name of the author may not be used to endorse or promote products |
16 | .\" derived from this software withough specific prior written permission |
17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | .Dd May 20, 1993 |
29 | .Dt INIT 8 |
30 | .Os 386BSD |
31 | .Sh NAME |
32 | .Nm init |
33 | .Nd ancestor of all user-level processes |
34 | .Sh SYNOPSIS |
35 | .Nm init |
36 | .Op Fl s |
37 | .Op Fl f |
38 | .Op Fl d Ar level |
39 | .Op Fl C Ar file |
40 | .Op Fl S |
41 | .Sh DESCRIPTION |
42 | .Nm init |
43 | is started by the Operating System kernel as the first user-level process |
44 | (PID 1). |
45 | It creates more processes to execute the system startup script |
46 | .Pa /etc/rc |
47 | and enable users to login. If the system startup fails for any reason, |
48 | it gives the system administrator a shell on the console. |
49 | Note that you cannot execute the |
50 | .Nm init |
51 | program directly (except if you are a UNIX kernel, which seems unlikely). |
52 | .Pp |
53 | .Em Options |
54 | .Bl -tag -width Ds -offset indent |
55 | .It Fl s |
56 | Starts a singleuser shell instead of booting the system to multiuser mode |
57 | .It Fl f |
58 | Fast boot. Calls the |
59 | .Pa /etc/rc |
60 | script without the |
61 | .Sy autoboot |
62 | argument, which causes it to skip disk checks |
63 | .It Fl d Ar level |
64 | Sets the debug level to the specified number. |
65 | .It Fl C Ar file |
66 | Causes |
67 | .Nm init |
68 | to read its configuration from file |
69 | .Ar file |
70 | instead of the default /etc/init.conf . |
71 | .It Fl S |
72 | Only checks the configuration file for syntax errors and exits immediately |
73 | afterwards. |
74 | .El |
75 | .Pp |
76 | .Em Singleuser and multiuser modes |
77 | .Bd -filled -offset indent |
78 | .Nm |
79 | knows of two states: |
80 | .Em singleuser |
81 | and |
82 | .Em multiuser |
83 | \&. The normal state is multiuser, where system daemons such as |
84 | .Xr crond 8 |
85 | or |
86 | .Xr inetd 8 |
87 | are active and the system accepts logins from direct connect ttys (with |
88 | .Xr getty 8 |
89 | ) and from the network. In singleuser mode, all daemons and user processes |
90 | terminated, and |
91 | .Nm |
92 | starts a shell on the system console. This shell can be used by the |
93 | system manager for administrative purposes. Because no proceses are running |
94 | that have files open, all file systems except the root file system can be |
95 | unmounted. |
96 | .Ed |
97 | .Pp |
98 | .Em System startup and shutdown |
99 | .Bd -filled -offset indent |
100 | When the system is booted, it creates process 1 and executes the file |
101 | .Pa /sbin/init |
102 | in it. The arguments that are given to the kernel are passed on to |
103 | the |
104 | .NM |
105 | program. Unless the |
106 | .Fl s |
107 | flag is specified, |
108 | .Nm |
109 | starts a shell to execute the |
110 | .Pa /etc/rc |
111 | script with the argument |
112 | .Sy "autoboot" |
113 | (Unless the |
114 | .Fl f |
115 | flag is specified, in which case the script is called without arguments). |
116 | This script checks and mounts file systems and starts |
117 | system daemons. If the script fails (exits with a status unequal to zero), |
118 | a shell is started on the console to enable the system administrator to |
119 | cure the problem. When this shell terminates, |
120 | .Nm |
121 | starts over by executing |
122 | .Pa /etc/rc |
123 | again (without arguments). When finally this script terminates with |
124 | an exit status of zero (signalling success), |
125 | .Nm |
126 | starts multiuser mode by reading the file |
127 | .Pa /etc/ttys |
128 | and starting getty processes for the terminals that are marked active |
129 | in this file. |
130 | .Pp |
131 | To bring the system from multiuser to singleuser mode, you can use |
132 | the |
133 | .Xr shutdown 8 |
134 | program. |
135 | .Ed |
136 | .Pp |
137 | .Em Signals |
138 | .Bd -filled -offset indent |
139 | The following list of signals is only here for completeness; You should |
140 | not send any signals to |
141 | .Nm init |
142 | directly, but instead use the |
143 | .Xr shutdown 8 |
144 | command to perform a state change. |
145 | .Bl -tag -width SIGTERM |
146 | .It SIGTERM |
147 | go to singleuser mode immediately. All processes are terminated, and then |
148 | a singleuser shell is started on the console. |
149 | .It SIGHUP |
150 | Reread the |
151 | .Pa /etc/ttys |
152 | file. |
153 | .It SIGTSTP |
154 | Drain the system. No new processes are created. The only way out of |
155 | this pseudo-state is another SIGHUP or SIGTERM signal. |
156 | .It SIGTTIN |
157 | Re-read the configuration file. Only valid when in Singleuser mode. |
158 | .It SIGUSR1 |
159 | Increase debugging level (if debugging is compiled in) |
160 | .It SIGUSR2 |
161 | Turn off debugging |
162 | .El |
163 | .Ed |
164 | .Pp |
165 | .Em Configuration |
166 | .Bd -filled -offset indent |
167 | Upon startup, |
168 | .Nm |
169 | reads the file |
170 | .Pa /etc/init.conf |
171 | or the file specified with the |
172 | .Fl C |
173 | option. |
174 | Each line in this file specifies a thing to configure. |
175 | Empty lines and lines with a hash character |
176 | .Sy # |
177 | as the first character are ignored. |
178 | .Bd -literal |
179 | limit LIMIT VALUE |
180 | hlimit LIMIT VALUE |
181 | .Ed |
182 | .Bd -filled -offset indent |
183 | set a soft or hard limit, respectively. LIMIT can be one of |
184 | .Sy cputime , |
185 | .Sy filesize , |
186 | .Sy datasize , |
187 | .Sy stacksize , |
188 | .Sy coredumpsize , |
189 | .Sy memoryuse , |
190 | .Sy memorylocked , |
191 | .Sy maxproc , |
192 | .Sy openfiles . |
193 | The VALUE is specified in bytes or seconds. See |
194 | .Xr setrlimit 2 |
195 | for more information. |
196 | .Pp |
197 | Note that you cannot raise hard limits. |
198 | Note also that the specified limits are not used for |
199 | .Nm init |
200 | itself, but for all processes it creates. |
201 | .Ed |
202 | .Bd -literal |
203 | setenv VARIABLE "VALUE" |
204 | .Ed |
205 | .Bd -filled -offset indent |
206 | Sets the specified environment-variable VAR with the specified VALUE. |
207 | VALUE can be ommitted. This setting is valid for all processes |
208 | on the system, except |
209 | .Nm init |
210 | itself. |
211 | .Ed |
212 | .Bd -literal |
213 | debug LEVEL |
214 | .Ed |
215 | .Bd -filled -offset indent |
216 | Sets the debug level of init to the specified value. Note that a level |
217 | specified with the |
218 | .Fl d |
219 | option takes precedence over this. |
220 | .Ed |
221 | .Bd -literal |
222 | startup_state { singleuser | multiuser } |
223 | .Ed |
224 | .Bd -filled -offset indent |
225 | Sets the default runlevel to singleuser or multiuser mode, respectively. |
226 | If |
227 | .Fl s |
228 | is specified, it always goes to singleuser mode. |
229 | .Ed |
230 | .Bd -literal |
231 | include "FILE" |
232 | .Ed |
233 | .Bd -filled -offset indent |
234 | Reads further configuration instructions from file "FILE" and continues in the |
235 | current file afterwards. Include commands can be nested up to a level of 50. |
236 | .Ed |
237 | .Bd -literal |
238 | singleusershell "COMMAND" |
239 | .Ed |
240 | .Bd -filled -offset indent |
241 | Lets you specify a command to execute as a singleuser shell. Note that the |
242 | first argument you specify is the 0th argument passed to the program. |
243 | Default is "/bin/sh -". |
244 | .Ed |
245 | .Bd -literal |
246 | singleuserterminal "TYPE" |
247 | .Ed |
248 | .Bd -filled -offset indent |
249 | Lets you specify a terminal type that is passed in the TERM environment |
250 | variable to the singleusershell. Default is "pc3". |
251 | .Ed |
252 | .Bd -literal |
253 | singleuserdevice "DEVICE" |
254 | .Ed |
255 | .Bd -filled -offset indent |
256 | Lets you specify a terminal device where the singleusershell will be started. |
257 | Default is "/dev/console". |
258 | .Ed |
259 | .Bd -literal |
260 | autobootcommand "COMMAND" |
261 | fastbootcommand "COMMAND" |
262 | .Ed |
263 | .Bd -filled -offset indent |
264 | Lets you specify a command that is executed when the system goes to multiuser |
265 | mode. The difference between the two is that autobootcommand is only executed |
266 | when the system starts multiuser mode immediately after boot, and only if |
267 | .Fl f |
268 | has not been specified. |
269 | If the system has already been in singleuser mode or |
270 | .Fl f |
271 | was used, fastbootcommand is used instead. The defaults are |
272 | "/bin/sh sh /etc/rc autoboot" for autobootcommand, and "/bin/sh sh /etc/rc" |
273 | for fastbootcommand. |
274 | .Ed |
275 | .Bd -literal |
276 | timeout shutdown sigterm TIME |
277 | timeout shutdown sigkill TIME |
278 | .Ed |
279 | .Bd -filled -offset indent |
280 | Normally, if you shutdown to singleuser mode, |
281 | .Nm init |
282 | sends a SIGTERM signal to all processes to give them a chance to |
283 | terminate gracefully, waits 10 seconds, then sends a SIGKILL to all |
284 | remaining processes and waits up to 30 seconds. You can change these timeouts |
285 | if you like. |
286 | .Ed |
287 | .Bd -literal |
288 | timeout error-retry TIME |
289 | .Ed |
290 | .Bd -filled -offset indent |
291 | If |
292 | .Nm init |
293 | encouters a serious problem (such as "fork failed" or "out of memory"), it |
294 | does not terminate, but instead continues its work and retries the operation |
295 | at a later time. The default is to retry after 300 seconds. |
296 | .Ed |
297 | .Bd -literal |
298 | respawn checkstatus { yes | no } |
299 | .Ed |
300 | .Bd -filled -offset indent |
301 | Specifies whether |
302 | .Nm init |
303 | should check the termination status of its children, in order to see if these |
304 | children fail (e.g. a getty on a non-existent device). The default is yes, |
305 | but you may want to switch it off if you have programs that don't return any |
306 | useful exit status. |
307 | .Ed |
308 | .Bd -literal |
309 | respawn checktime { yes | no | TIME } |
310 | .Ed |
311 | .Bd -filled -offset indent |
312 | Specifies whether or not |
313 | .Nm init |
314 | should assume that children that did not live longer than TIME seconds |
315 | were failing. The default is yes, which is equivalent to a time of 5 seconds. |
316 | 0 is equivalent to no. |
317 | .Ed |
318 | .Sh ENVIRONMENT |
319 | The UNIX kernel sets up the environment for |
320 | .Nm init |
321 | as part of its initialisation. |
322 | Specifically, |
323 | .Nm |
324 | is called without any files open. |
325 | .Sh FILES |
326 | .Bl -tag -width "/etc/init.conf" -compact |
327 | .It Pa /etc/init.conf |
328 | Configuration file for |
329 | .Nm init |
330 | (See |
331 | .Sx DESCRIPTION |
332 | above) |
333 | .It Pa /etc/rc |
334 | System Startup Script |
335 | .It Pa /etc/ttys |
336 | specifies on which terminals to create login processes |
337 | .El |
338 | .Sh DIAGNOSTICS |
339 | .Nm init |
340 | logs all messages via |
341 | .Xr syslogd 8 |
342 | with the |
343 | .Sy LOG_DAEMON |
344 | facility. |
345 | If it cannot open a connectoin to a syslogd, it prints the message |
346 | to the console. Fatal errors (such as a segmentaion fault) cause |
347 | the kernel to panic with the message "init died". |
348 | .Sh SEE ALSO |
349 | .Xr rc 8 , |
350 | .Xr getty 8 , |
351 | .Xr syslogd 8 , |
352 | .Xr ttys 5 , |
353 | .Xr shutdown 8 |
354 | .Sh AUTHOR |
355 | This incarnation of |
356 | .Nm init |
357 | was written by Christoph Robitschko for the 386BSD project. |
358 | .Sh BUGS |
359 | \&... should be reported to <chmr@edvz.tu-graz.ac.at> |