Hardware Reference
In-Depth Information
inittab Action respawn
The
respawn
option is often used for processes that manage terminal lines (gettys).
The following example is taken from the standard Raspbian
/etc/inittab
:
# Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty −L ttyAMA0 115200 vt100
This entry is used whenever
init
enters run levels 2 or 3. It launches program
/sbin/getty
to prompt the user for login on the serial console device
(/dev/ttyAMA0
in
this example). Other command-line parameters help the
getty
program to configure the
terminal and login environment. When the user logs out of his session, the
getty
process
terminates. When
init
notices that the process has terminated, it starts
/sbin/getty
again because of the
respawn
action. In this way, the terminal line is readied for the next
user login.
■
When using the
respawn
action for your own application, be careful that it
doesn't fail frequently. otherwise,
init
will churn by repeatedly restarting your process after
it fails. You may eventually get a message on the console with
init
temporarily suspending
the entry. this reduces the hogging of system resources from frequent respawning. But this
suspension is temporary.
Caution
Changing Run Levels
The preceding sections outlined the startup procedure. Let's now examine what happens
when you change run levels.
telinit
The
/sbin/telinit
executable is linked to the
init
program file
/sbin/init
. This form
of the command is used to inform the executing
init
process to request a change of run
levels:
# telinit x
where
x
is the new run level to enter. The run level may be specified only as one of the
choices described in Table
3-4
.