INIT(1M-SysV) RISC/os Reference Manual INIT(1M-SysV)
NAME
init, telinit - process control initialization
SYNOPSIS
/etc/init [0123456SsQq]
/etc/telinit [0123456sSQqabc]
DESCRIPTION
Init
init is a general process spawner. Its primary role is to
create processes from information stored in the file
/etc/inittab (see inittab(4)). This file usually has init
spawn getty's on each line that a user may log in on. It
also controls autonomous processes required by any particu-
lar system.
init considers the system to be in a run-level at any given
time. A run-level can be viewed as a software configuration
of the system where each configuration allows only a
selected group of processes to exist. The processes spawned
by init for each of these run-levels is defined in the init-
tab file. init can be in one of eight run-levels, 0-6 and S
or s. The run-level is changed by having a privileged user
run /etc/init. This user-spawned init sends appropriate
signals to the original init spawned by the operating system
when the system was rebooted, telling it which run-level to
change to.
init is invoked inside the UNIX system as the last step in
the boot procedure. First init looks in /etc/inittab for
the initdefault entry (see inittab(4)). If there is one,
init uses the run-level specified in that entry as the ini-
tial run-level to enter. If this entry is not in
/etc/inittab, init requests that the user enter a run-level
from the virtual system console, /dev/console. If an S or an
s is entered, init goes into the SINGLE USER state. This is
the only run-level that doesn't require the existence of a
properly formatted /etc/inittab file. If it doesn't exist,
then by default the only legal run-level that init can enter
is the SINGLE USER state. In the SINGLE USER state the vir-
tual console terminal /dev/console is opened for reading and
writing and the command /bin/su is invoked immediately. To
exit from the SINGLE USER state, use either init or telinit,
to signal init to change the run-level of the system. Note
that if the shell is terminated (via an end-of-file), init
will only re-initialize to the SINGLE USER state.
When attempting to boot the system, failure of init to
prompt for a new run-level may be due to the fact that the
device /dev/console is linked to a device other than the
physical system console (/dev/contty). If this occurs, init
Printed 1/15/91 Page 1
INIT(1M-SysV) RISC/os Reference Manual INIT(1M-SysV)
can be forced to relink /dev/console by typing a delete on
the system console which is colocated 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 or s is entered, init operates as previously
described in the SINGLE USER state with the additional
result that /dev/console is linked to the user's terminal
line, thus making it the virtual system console. A message
is generated on the physical console, /dev/contty, 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/console, to those modes
saved in the file /etc/ioctl.syscon. This file is written
by init whenever the SINGLE USER state is entered.
If a 0 through 6 is entered init enters the corresponding
run-level. Any other input will be rejected and the user
will be re-prompted. Note that, on the 3B2 Computer, the
run-levels 0, 1, 5, and 6 are reserved states for shutting
the system down; the run-levels 2, 3, and 4 are available as
normal operating states.
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, providing 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 defined to contain all of the terminal
processes and daemons that are spawned in the multi-user
environment. Hence, it is commonly referred to as the
MULTI-USER state. run-level 3 is defined to start up remote
file sharing processes and daemons as well as mount and
advertise remote resources. So, run-level 3 extends multi-
user mode and is know as the Remote File Sharing state.
run-level 4 is available to be defined as an alternative
multi-user environment configuration, however, it is not
necessary for system operation and is usually unused.
In a MULTI-USER environment, the inittab file is set up so
that init will create a process for each terminal on the
system that the administrator sets up to respawn.
Page 2 Printed 1/15/91
INIT(1M-SysV) RISC/os Reference Manual INIT(1M-SysV)
For terminal processes, ultimately the shell will terminate
because of an end-of-file either typed explicitly or gen-
erated as the result of hanging up. When init receives a
signal telling it that a process it spawned has died, it
records the fact and the reason it died in /etc/utmp and
/etc/wtmp if it exists (see who(1)). A history of the
processes spawned is kept in /etc/wtmp.
To spawn each process in the inittab file, init reads each
entry and for each entry that should be respawned, it forks
a child process. After it has spawned all of the processes
specified by the inittab file, init waits for one of its
descendant processes to die, a powerfail signal, or until
init is signaled by init or telinit 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 the above three conditions to occur. To get around this,
init Q or init q command wakes init to re-examine the init-
tab file immediately.
If init receives a powerfail signal (SIGPWR) it scans init-
tab for special entries of the type powerfail and powerwait.
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 during the
powerdown of the operating system. Note that in the
SINGLE-USER state only powerfail and powerwait entries are
executed.
When init is requested to change run-levels (via telinit),
init sends the warning signal (SIGTERM) to all processes
that are undefined in the target run-level. init waits 5
seconds before forcibly terminating these processes via the
kill signal (SIGKILL).
Telinit
Telinit, which is linked to /etc/init, is used to direct the
actions of init. It takes a one-character argument and sig-
nals init via the kill system call to perform the appropri-
ate action. The following arguments serve as directives to
init.
0-6 tells init to place the system in one of
the run-levels 0-6.
a,b,c tells init to process only those
/etc/inittab file entries having the a,
b or c run-level set. These are
pseudo-states, which may be defined to
run certain commands, but which do not
cause the current run-level to change.
Printed 1/15/91 Page 3
INIT(1M-SysV) RISC/os Reference Manual INIT(1M-SysV)
Q,q tells init to re-examine the
/etc/inittab file.
s,S tells init to enter the single user
environment. When this level change is
effected, the virtual system teletype,
/dev/console, is changed to the terminal
from which the command was executed.
FILES
/etc/inittab
/etc/utmp
/etc/wtmp
/etc/ioctl.syscon
/dev/console
/dev/contty
SEE ALSO
getty(1M), termio(7).
login(1), sh(1), who(1) in the User's Reference Manual.
kill(2), inittab(4), utmp(4) in the Programmer's Reference
Manual.
DIAGNOSTICS
If init finds that it is respawning an entry from
/etc/inittab more than 10 times in 2 minutes, it will assume
that there is an error in the command string in the entry,
and generate an error message on the system console. It
will then refuse to respawn this entry until either 5
minutes has elapsed or it receives a signal from a user-
spawned init (telinit). This prevents init from eating up
system resources when someone makes a typographical error in
the inittab file or a program is removed that is referenced
in the inittab.
WARNINGS
Telinit can be run only by someone who is super-user or a
member of group sys.
If the key switch on an M120 system is in the LOCKED posi-
tion, the state of the system can not be changed. A diag-
nostic is printed to this effect.
ERRORS
Attempting to relink /dev/console with /dev/contty by typing
a delete on the system console does not work.
Page 4 Printed 1/15/91