| Rev | Author | # | Line |
|---|---|---|---|
| 1 | perry | 1 | !!!INIT |
| 3 | JohnMcPherson | 2 | |
| 3 | |||
| 1 | perry | 4 | !!NAME |
| 5 | |||
| 6 | |||
| 7 | init, telinit - process control initialization | ||
| 8 | !!SYNOPSIS | ||
| 9 | |||
| 10 | |||
| 3 | JohnMcPherson | 11 | __/sbin/init__ [[ __-a__ ] [[ __-s__ ] [[ __-b__ ] [[ __-z xxx__ ] [[ __0123456Ss__ ] |
| 1 | perry | 12 | |
| 3 | JohnMcPherson | 13 | __/sbin/telinit__ [[ __-t sec__ ] [[__0123456sSQqabcUu__ ] |
| 1 | perry | 14 | |
| 15 | |||
| 3 | JohnMcPherson | 16 | !!DESCRIPTION |
| 1 | perry | 17 | |
| 18 | __Init__ is the parent of all processes. Its primary role | ||
| 19 | is to create processes from a script stored in the file | ||
| 20 | __/etc/inittab__ (see inittab(5)). This file | ||
| 21 | usually has entries which cause __init__ to spawn | ||
| 22 | __getty__s on each line that users can log in. It also | ||
| 23 | controls autonomous processes required by any particular | ||
| 24 | system. | ||
| 25 | |||
| 3 | JohnMcPherson | 26 | !!RUNLEVELS |
| 1 | perry | 27 | |
| 28 | A ''runlevel'' is a software configuration of the system | ||
| 29 | which allows only a selected group of processes to exist. | ||
| 30 | The processes spawned by __init__ for each of these | ||
| 31 | runlevels are defined in the __/etc/inittab__ file. | ||
| 32 | __Init__ can be in one of eight runlevels: __0-6__ and | ||
| 33 | __S__ or __s__. The runlevel is changed by having a | ||
| 34 | privileged user run __telinit__, which sends appropriate | ||
| 35 | signals to __init__, telling it which runlevel to change | ||
| 36 | to. | ||
| 37 | |||
| 38 | |||
| 39 | Runlevels __0__, __1__, and __6__ are reserved. | ||
| 40 | Runlevel 0 is used to halt the system, runlevel 6 is used to | ||
| 41 | reboot the system, and runlevel 1 is used to get the system | ||
| 42 | down into single user mode. Runlevel __S__ is not really | ||
| 43 | meant to be used directly, but more for the scripts that are | ||
| 44 | executed when entering runlevel 1. For more information on | ||
| 45 | this, see the manpages for shutdown(8) and | ||
| 46 | inittab(5). | ||
| 47 | |||
| 48 | |||
| 49 | Runlevels 7-9 are also valid, though not really documented. | ||
| 50 | This is because | ||
| 51 | S'' and | ||
| 52 | ''s'' are in fact the same. Internally they are aliases | ||
| 53 | for the same runlevel. | ||
| 54 | |||
| 3 | JohnMcPherson | 55 | !!BOOTING |
| 1 | perry | 56 | |
| 57 | After __init__ is invoked as the last step of the kernel | ||
| 58 | boot sequence, it looks for the file __/etc/inittab__ to | ||
| 59 | see if there is an entry of the type __initdefault__ (see | ||
| 60 | inittab(5)). The __initdefault__ entry determines | ||
| 61 | the initial runlevel of the system. If there is no such | ||
| 62 | entry (or no __/etc/inittab__ at all), a runlevel must be | ||
| 63 | entered at the system console. | ||
| 64 | |||
| 65 | Runlevel __S__ or __s__ bring the system to single | ||
| 66 | user mode and do not require an __/etc/inittab__ file. In | ||
| 67 | single user mode, __/sbin/sulogin__ is invoked on | ||
| 68 | __/dev/console__. | ||
| 69 | |||
| 70 | When entering single user mode, __init__ reads the | ||
| 71 | console's ioctl(2) states from | ||
| 72 | __/etc/ioctl.save__. If this file does not exist, | ||
| 73 | __init__ initializes the line at __9600 baud__ and | ||
| 74 | with __CLOCAL__ settings. When __init__ leaves single | ||
| 75 | user mode, it stores the console's ''ioctl'' settings in | ||
| 76 | this file so it can re-use them for the next single-user | ||
| 77 | session. | ||
| 78 | |||
| 79 | When entering a multi-user mode for the first time, | ||
| 80 | __init__ performs the __boot__ and __bootwait__ | ||
| 81 | entries to allow file systems to be mounted before users can | ||
| 82 | log in. Then all entries matching the runlevel are | ||
| 83 | processed. | ||
| 84 | |||
| 85 | When starting a new process, __init__ first checks | ||
| 86 | whether the file ''/etc/initscript'' exists. If it does, | ||
| 87 | it uses this script to start the process. | ||
| 88 | |||
| 89 | Each time a child terminates, __init__ records the fact | ||
| 90 | and the reason it died in __/var/run/utmp__ and | ||
| 91 | __/var/log/wtmp__, provided that these files | ||
| 92 | exist. | ||
| 93 | |||
| 3 | JohnMcPherson | 94 | !!CHANGING RUNLEVELS |
| 1 | perry | 95 | |
| 96 | After it has spawned all of the processes specified, | ||
| 97 | __init__ waits for one of its descendant processes to | ||
| 98 | die, a powerfail signal, or until it is signaled by | ||
| 99 | __telinit__ to change the system's runlevel. When one of | ||
| 100 | the above three conditions occurs, it re-examines the | ||
| 101 | __/etc/inittab__ file. New entries can be added to this | ||
| 102 | file at any time. However, __init__ still waits for one | ||
| 103 | of the above three conditions to occur. To provide for an | ||
| 104 | instantaneous response, the __telinit Q__ or __q__ | ||
| 105 | command can wake up __init__ to re-examine the | ||
| 106 | __/etc/inittab__ file. | ||
| 107 | |||
| 108 | If __init__ is not in single user mode and receives a | ||
| 109 | powerfail signal (SIGPWR), it reads the file | ||
| 110 | __/etc/powerstatus__. It then starts a command based on | ||
| 111 | the contents of this file: | ||
| 112 | |||
| 113 | F(AIL) | ||
| 114 | |||
| 115 | Power is failing, UPS is providing the power. Execute the | ||
| 116 | __powerwait__ and __powerfail__ entries. | ||
| 117 | |||
| 118 | O(K) | ||
| 119 | |||
| 120 | The power has been restored, execute the __powerokwait__ | ||
| 121 | entries. | ||
| 122 | |||
| 123 | L(OW) | ||
| 124 | |||
| 125 | The power is failing and the UPS has a low battery. Execute | ||
| 126 | the __powerfailnow__ entries. | ||
| 127 | |||
| 128 | If /etc/powerstatus doesn't exist or contains anything else | ||
| 129 | then the letters __F__, __O__ or __L__, init will | ||
| 130 | behave as if it has read the letter __F__. | ||
| 131 | |||
| 132 | Usage of __SIGPWR__ and __/etc/powerstatus__ is | ||
| 133 | discouraged. Someone wanting to interact with __init__ | ||
| 134 | should use the __/dev/initctl__ control channel - see the | ||
| 135 | source code of the __sysvinit__ package for more | ||
| 136 | documentation about this. | ||
| 137 | |||
| 138 | When __init__ is requested to change the runlevel, it | ||
| 139 | sends the warning signal __SIGTERM__ to | ||
| 140 | all processes that are undefined in the new runlevel. It | ||
| 141 | then waits 5 seconds before forcibly terminating these | ||
| 142 | processes via the __SIGKILL__ signal. Note | ||
| 143 | that __init__ assumes that all these processes (and their | ||
| 144 | descendants) remain in the same process group which | ||
| 145 | __init__ originally created for them. If any process | ||
| 146 | changes its process group affiliation it will not receive | ||
| 147 | these signals. Such processes need to be terminated | ||
| 148 | separately. | ||
| 3 | JohnMcPherson | 149 | |
| 1 | perry | 150 | !!TELINIT |
| 151 | |||
| 152 | __/sbin/telinit__ is linked to __/sbin/init__. It | ||
| 153 | takes a one-character argument and signals __init__ to | ||
| 154 | perform the appropriate action. The following arguments | ||
| 155 | serve as directives to __telinit__: | ||
| 156 | |||
| 157 | __0__,__1__,__2__,__3__,__4__,__5__ or | ||
| 158 | __6__ | ||
| 159 | |||
| 160 | tell __init__ to switch to the specified run | ||
| 161 | level. | ||
| 162 | |||
| 163 | __a__,__b__,__c__ | ||
| 164 | |||
| 165 | tell __init__ to process only those __/etc/inittab__ | ||
| 166 | file entries having runlevel __a__,__b__ or | ||
| 167 | __c__. | ||
| 168 | |||
| 169 | |||
| 170 | __Q__ or __q__ | ||
| 171 | |||
| 172 | |||
| 173 | tell __init__ to re-examine the __/etc/inittab__ | ||
| 174 | file. | ||
| 175 | |||
| 176 | |||
| 177 | __S__ or __s__ | ||
| 178 | |||
| 179 | |||
| 180 | tell __init__ to switch to single user mode. | ||
| 181 | |||
| 182 | |||
| 183 | __U__ or __u__ | ||
| 184 | |||
| 185 | |||
| 186 | tell __init__ to re-execute itself (preserving the | ||
| 187 | state). No re-examining of __/etc/inittab__ file happens. | ||
| 188 | Run level should be one of __Ss12345__, otherwise request | ||
| 189 | would be silently ignored. | ||
| 190 | |||
| 191 | |||
| 192 | __telinit__ can also tell __init__ how long it should | ||
| 193 | wait between sending processes the SIGTERM and SIGKILL | ||
| 194 | signals. The default is 5 seconds, but this can be changed | ||
| 195 | with the __-t sec__ option. | ||
| 196 | |||
| 197 | |||
| 198 | __telinit__ can be invoked only by users with appropriate | ||
| 199 | privileges. | ||
| 200 | |||
| 201 | |||
| 202 | The __init__ binary checks if it is __init__ or | ||
| 203 | __telinit__ by looking at its ''process id''; the real | ||
| 204 | __init__'s process id is always __1__. From this it | ||
| 205 | follows that instead of calling __telinit__ one can also | ||
| 206 | just use __init__ instead as a shortcut. | ||
| 207 | !!ENVIRONMENT | ||
| 208 | |||
| 209 | |||
| 210 | __Init__ sets the following environment variables for all | ||
| 211 | its children: | ||
| 212 | |||
| 213 | |||
| 214 | __PATH__ | ||
| 215 | |||
| 216 | |||
| 217 | ''/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin'' | ||
| 218 | |||
| 219 | |||
| 220 | __INIT_VERSION__ | ||
| 221 | |||
| 222 | |||
| 223 | As the name says. Useful to determine if a script runs | ||
| 224 | directly from __init__. | ||
| 225 | |||
| 226 | |||
| 227 | __RUNLEVEL__ | ||
| 228 | |||
| 229 | |||
| 230 | The current system runlevel. | ||
| 231 | |||
| 232 | |||
| 233 | __PREVLEVEL__ | ||
| 234 | |||
| 235 | |||
| 236 | The previous runlevel (useful after a runlevel | ||
| 237 | switch). | ||
| 238 | |||
| 239 | |||
| 240 | __CONSOLE__ | ||
| 241 | |||
| 242 | |||
| 243 | The system console. This is really inherited from the | ||
| 244 | kernel; however if it is not set __init__ will set it to | ||
| 245 | __/dev/console__ by default. | ||
| 3 | JohnMcPherson | 246 | |
| 247 | |||
| 1 | perry | 248 | !!BOOTFLAGS |
| 249 | |||
| 250 | It is possible to pass a number of flags to __init__ from | ||
| 251 | the boot monitor (eg. LILO). __Init__ accepts the | ||
| 252 | following flags: | ||
| 253 | |||
| 254 | |||
| 255 | __-s, S, single__ | ||
| 256 | |||
| 257 | |||
| 258 | Single user mode boot. In this mode ''/etc/inittab'' is | ||
| 259 | examined and the bootup rc scripts are usually run before | ||
| 260 | the single user mode shell is started. | ||
| 261 | |||
| 262 | __1-5__ | ||
| 263 | |||
| 264 | Runlevel to boot into. | ||
| 265 | |||
| 266 | __-b, emergency__ | ||
| 267 | |||
| 268 | Boot directly into a single user shell without running any | ||
| 269 | other startup scripts. | ||
| 270 | |||
| 271 | __-a, auto__ | ||
| 272 | |||
| 3 | JohnMcPherson | 273 | The LILO boot loader adds the word "auto" to the command line if |
| 274 | it booted the kernel with the default command line (without | ||
| 275 | user intervention). If this is found init sets the "AUTOBOOT" | ||
| 276 | environment variable to "yes". Note that you cannot use this | ||
| 277 | for any security measures ‐ of course the user could specify | ||
| 278 | "auto" or -a on the command line manually. | ||
| 1 | perry | 279 | |
| 280 | |||
| 281 | |||
| 282 | __-z xxx__ | ||
| 283 | |||
| 284 | |||
| 285 | The argument to -z is ignored. You can use this to expand | ||
| 286 | the command line a bit, so that it takes some more space on | ||
| 287 | the stack. __Init__ can then manipulate the command line | ||
| 288 | so that ps(1) shows the current | ||
| 289 | runlevel. | ||
| 290 | !!INTERFACE | ||
| 291 | |||
| 292 | |||
| 293 | Init listens on a ''fifo'' in /dev, ''/dev/initctl'', | ||
| 294 | for messages. __Telinit__ uses this to communicate with | ||
| 295 | init. The interface is not very well documented or finished. | ||
| 296 | Those interested should study the ''initreq.h'' file in | ||
| 297 | the ''src/'' subdirectory of the __init__ source code | ||
| 298 | tar archive. | ||
| 299 | !!SIGNALS | ||
| 300 | |||
| 301 | |||
| 302 | Init reacts to several signals: | ||
| 303 | |||
| 304 | |||
| 305 | __SIGHUP__ | ||
| 306 | |||
| 307 | |||
| 308 | Init looks for ''/etc/initrunlvl'' and | ||
| 309 | ''/var/log/initrunlvl.'' If one of these files exist and | ||
| 310 | contain an ASCII runlevel, init switches to the new | ||
| 311 | runlevel. ''This is for backwards compatibility only!'' . | ||
| 312 | In the normal case (the files don't exist) init behaves like | ||
| 313 | __telinit q__ was executed. | ||
| 314 | |||
| 315 | |||
| 316 | __SIGUSR1__ | ||
| 317 | |||
| 318 | |||
| 319 | On receipt of this signals, init closes and re-opens its | ||
| 320 | control fifo, __/dev/initctl__. Useful for bootscripts | ||
| 321 | when /dev is remounted. | ||
| 322 | |||
| 323 | |||
| 324 | __SIGINT__ | ||
| 325 | |||
| 326 | |||
| 327 | Normally the kernel sends this signal to init when | ||
| 328 | CTRL-ALT-DEL is pressed. It activates the ''ctrlaltdel'' | ||
| 329 | action. | ||
| 330 | |||
| 331 | |||
| 332 | __SIGWINCH__ | ||
| 333 | |||
| 334 | |||
| 2 | perry | 335 | The kernel sends this signal when the ''!KeyboardSignal'' |
| 1 | perry | 336 | key is hit. It activates the ''kbrequest'' |
| 337 | action. | ||
| 338 | !!CONFORMING TO | ||
| 339 | |||
| 340 | |||
| 341 | __Init__ is compatible with the System V init. It works | ||
| 342 | closely together with the scripts in the directories | ||
| 343 | ''/etc/init.d'' and ''/etc/rc{runlevel}.d''. If your | ||
| 344 | system uses this convention, there should be a ''README'' | ||
| 345 | file in the directory ''/etc/init.d'' explaining how | ||
| 346 | these scripts work. | ||
| 347 | !!FILES | ||
| 348 | |||
| 349 | |||
| 350 | /etc/inittab | ||
| 351 | /etc/initscript | ||
| 352 | /dev/console | ||
| 353 | /etc/ioctl.save | ||
| 354 | /var/run/utmp | ||
| 355 | /var/log/wtmp | ||
| 356 | /dev/initctl | ||
| 357 | !!WARNINGS | ||
| 358 | |||
| 359 | |||
| 360 | __Init__ assumes that processes and descendants of | ||
| 361 | processes remain in the same process group which was | ||
| 362 | originally created for them. If the processes change their | ||
| 363 | group, __init__ can't kill them and you may end up with | ||
| 364 | two processes reading from one terminal line. | ||
| 365 | !!DIAGNOSTICS | ||
| 366 | |||
| 367 | |||
| 368 | If __init__ finds that it is continuously respawning an | ||
| 369 | entry more than 10 times in 2 minutes, it will assume that | ||
| 370 | there is an error in the command string, generate an error | ||
| 371 | message on the system console, and refuse to respawn this | ||
| 372 | entry until either 5 minutes has elapsed or it receives a | ||
| 373 | signal. This prevents it from eating up system resources | ||
| 374 | when someone makes a typographical error in the | ||
| 375 | __/etc/inittab__ file or the program for the entry is | ||
| 376 | removed. | ||
| 377 | !!AUTHOR | ||
| 378 | |||
| 379 | |||
| 3 | JohnMcPherson | 380 | Miquel van Smoorenburg (miquels''@''cistron.nl), initial manual |
| 1 | perry | 381 | page by Michael Haardt |
| 3 | JohnMcPherson | 382 | (u31b3hs''@''pool.informatik.rwth-aachen.de). |
| 383 | |||
| 1 | perry | 384 | !!SEE ALSO |
| 385 | |||
| 386 | |||
| 387 | getty(1), login(1), sh(1), | ||
| 3 | JohnMcPherson | 388 | runlevel(8), shutdown(8), kill(1), |
| 1 | perry | 389 | inittab(5), initscript(5), |
| 390 | utmp(5) | ||
| 391 | ---- |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 32 times)