init(1M) init(1M)NAME init, telinit - spawn general processes SYNOPSIS init [run-level [directive]] ARGUMENTS directive Causes init to perform specific tasks. Replace directive with one of the following: a Causes init to create or remove only those processes with an ``a'' in their run-level field in /etc/inittab. Affected processes may be switched on or off as specified in the action field (see inittab(4)). b Causes init to create or remove only those processes with a ``b'' in their run-level field in /etc/inittab. Affected processes may be switched on or off as specified in the action field (see inittab(4)). c Causes init to create or remove only those processes with a ``c'' in their run-level field in /etc/inittab. Affected processes may be switched on or off as specified in the action field (see inittab(4)). q Q Causes init to re-examine the /etc/inittab file and honor any changes that apply to the current run level. For example, a getty process that is changed from respawn to off in /etc/inittab will be killed when init q is entered. run-level Specifies a number between one and six or the letters s or S. When used, init places the system in the specified run level. Using s or S causes init to change the virtual system teletype, /dev/syscon, to the terminal from which the command was executed, as well as to establish the corresponding run level (which is single-user). A run level can be viewed as a software configuration that must, at minimum, consist of the processes specified in /etc/inittab for that run level. January 1992 1
init(1M) init(1M)DESCRIPTION init is a general process spawner. Its primary role is to create processes based on the line entries in /etc/inittab (see inittab(4)). This file usually instructs init to spawn terminal listeners (see getty(1M)) on each serial line available for access to the system. It can also manage the system's autonomous processes, often called daemons. For interchangeable use, telinit is linked to init (see ln(1)). Normally, the permissions are set so that telinit and init can only be run by the superuser or a member of the group sys. Besides using init to change the run level, it can be used to help switch various processes on and off in tandem (see directives, previously described). An init process is run as part of A/UX initialization, and that copy of the program must run continuously. It maintains the system state. By invoking the init program again, at the command line, the original copy of init can be instructed to change the system's run level. The newly requested copy of init sends the appropriate signals to the one created at system startup. Following is a description of the role init plays in the startup process, and gives examples of the special processing init performs when there is a change in run level or in the status of a process (termination). First init looks for an entry in /etc/inittab in which initdefault appears in the action field (see inittab(4)). If there is one, init uses the run level specified in that entry as the initial run level to enter. If this entry is not in inittab or inittab is not found, init requests that the user enter a run level from the virtual system console, /dev/syscon. If an S (s) is entered, init goes into the single-user level. This is the only run level that doesn't require the existence of a properly formatted inittab file. If /etc/inittab doesn't exist, then, by default, the only legal run level that init can enter is the single-user level. In the single-user level, the virtual console terminal /dev/syscon is opened for reading and writing and the command /bin/su is invoked immediately. To exit from the single-user run level, one of two flag options can be elected. First, if the shell is terminated (via an end-of- file), init reprompts for a new run level. Second, the init command can signal init and force it to change the run level of the system. When attempting to boot the system, failure of init to prompt for a new run level may be due to the fact that the 2 January 1992
init(1M) init(1M)device /dev/syscon is linked to a device other than the physical system teletype (/dev/systty). If this occurs, init can be forced to relink /dev/syscon by typing a delete on the system teletype which is co-located with the processor. When init prompts for the new run level, the operator may enter only one of the digits 0 through 6 or the letters S or s. If S is entered init operates as previously described in single-user mode with the additional result that /dev/syscon is linked to the user's terminal line, thus making it the virtual system console. A message is generated on the physical console, /dev/systty, saying where the virtual terminal has been relocated. When init comes up initially and whenever it switches out of single-user state to normal run states, it sets the ioctl(2) states of the virtual console, /dev/syscon, to those modes saved in the file /etc/ioctl.syscon. This file is written by init whenever single-user mode is entered. If this file does not exist when init wants to read it, a warning is printed and default settings are assumed. If a 0 through 6 is entered, init enters the corresponding run level. Any other input will be rejected and the user will be reprompted. If this is the first time init has entered a run level other than single-user, init first scans inittab for special entries of the type boot and bootwait. These entries are performed, provided that the run level entered matches that of the entry before any normal processing of inittab takes place. In this way, any special initialization of the operating system, such as mounting file systems, can take place before users are allowed onto the system. The inittab file is scanned to find all entries that are to be processed for that run level. Run level 2 is usually defined by the user to contain all of the terminal processes and daemons that are spawned in the multiuser environment. In a multiuser environment, the inittab file is usually set up so that init will create a process for each terminal on the system. For terminal processes, the shell will ultimately terminate because an end-of-file was either typed explicitly or generated as a result of hanging up. When init receives a child-death signal, reporting the death of a process it has spawned, it records the death and the cause of death in /etc/utmp, and in /etc/wtmp if it exists (see who(1)). A history of the processes spawned is kept in /etc/wtmp if such a file exists. January 1992 3
init(1M) init(1M)To spawn each process in the inittab file, init reads each entry and forks a child process for each entry that should be respawned. After it has spawned all of the processes specified by the inittab file, init waits for one of its descendant processes to die, for a power-failure signal, or until it is signaled by init to change the system's run level. When one of these conditions occurs, init re- examines the inittab file. New entries can be added to the inittab file at any time; however, init still waits for one of these conditions. To process the altered or new entries in /etc/inittab immediately, use the command init Q or init q to awaken init and make it re-examine the inittab file. If init receives a power-failure signal (SIGPWR) and is not in single-user mode, it scans inittab for special powerfail entries. These entries are invoked (if the run levels permit) before any further processing takes place. In this way, init can perform various cleanup and recording functions whenever the operating system experiences a power failure. When init is requested to change run levels, init sends the warning signal (SIGTERM) to all processes that are undefined in the target run level. init waits 20 seconds before forcibly terminating these processes via the kill signal (SIGKILL). When the q or Q option is specified init removes processes that are currently running but which are set to be off in /etc/inittab for the current run level. STATUS MESSAGES AND VALUES If init finds that it is continuously respawning an entry from /etc/inittab more than 10 times in 2 minutes, it assumes that there is an error in the command string and will generate an error message on the system console. init refuses to respawn this entry until either 5 minutes has elapsed or it receives a signal from a user init. This prevents init from monopolizing system resources when someone makes a typographical error in inittab file or a program is removed that is referenced in inittab. FILES /etc/init Executable file /etc/inittab File containing initialization table /etc/utmp Temporary file /etc/wtmp Temporary file /etc/ioctl.syscon Configuration file /dev/syscon 4 January 1992
init(1M) init(1M)Configuration file /dev/systty File containing list of terminal types SEE ALSO getty(1M) login(1), sh(1), who(1) in A/UX Command Reference kill(2), inittab(4), ioctl.syscon(4), utmp(4) in A/UX Programmer's Reference ``System Startup and Shutdown'' in A/UX Local System Administration January 1992 5