summaryrefslogtreecommitdiff
path: root/static/v10/man8/init.8
blob: 72def2a815b7426c9ad997d5c0b51e68a19fe128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.TH INIT 8
.CT 1 sa_auto secur
.SH NAME
init \- process control initialization
.SH SYNOPSIS
.B /etc/init
.SH DESCRIPTION
.I Init
is invoked by the kernel as the last step in the boot procedure.
It is always process 1.
.PP
When started normally,
.I init
calls
.IR rc (8).
The security label is set at bottom.
If this succeeds,
.I init
begins multi-user operation.
If
.I rc
fails,
.I init
commences single user operation by executing
a superuser shell,
.IR nosh (8),
with bottom security label, top ceiling, and all privileges.
.PP
When started by a cold boot from the console,
.I init
starts single user operation immediately.
When the single user shell terminates,
.I init
runs
.IR rc
without the parameter,
and begins multi-user operation.
.PP
In multi-user operation,
.IR init 's
role is to create a process for each
directly connected terminal port on which a user may log in.
To begin such operations, it reads the
.IR ttys (5)
file and forks to create a process
for each terminal specified in the file.
Each of these processes opens the appropriate terminal
for reading and writing
on file descriptors 0, 1, 2, and 3 (the standard input and
output, the diagnostic output and
.FR /dev/tty ).
The security label of each port is set to that of file
.FR /etc/floor .
Opening the terminal will usually involve a delay,
since the
.I open 
is not completed until someone
dials and carrier is established on the channel.
Then
.IR getty (8)
is called with argument as specified by the second character of
the
.I ttys
file line.
.I Getty
reads the user's name and invokes
.IR login (8)
to log in the user and execute the shell.
.PP
Ultimately the shell will terminate
because of an end-of-file or as a result of hanging up.
The main path of
.IR init ,
which has been waiting
for such an event,
wakes up and removes the appropriate entry from the
file
.IR utmp (5),
which records current users, and
makes an entry in
.IR wtmp ,
which maintains a history
of logins and logouts.
Then the appropriate terminal is reopened and
.I getty
is
invoked again.
.PP
.I Init
catches signal
.B SIGHUP
and interprets it to mean that
the
.I ttys
file
should be read again.
The shell process on each line that has become inactive 
according to
.I ttys
is terminated;
a new process is created for each line added;
lines unchanged in the file are undisturbed.
Thus it is possible to drop or add terminal lines without
rebooting the system by changing the
.I ttys
file and sending a
.I hangup
signal to the
.I init
process: use
.LR "kill -1 1" .
.PP
.I Init
will terminate multi-user operations,
kill all outstanding processes,
and resume single-user mode
if sent signal
.BR SIGTERM :
use
.LR "kill 1" .
.I Init
will wait at most 30 seconds for outstanding processes to die,
to avoid waiting forever.
.PP
If, at bootstrap time, the
.I init
program cannot be executed,
the system will loop in user mode at a low address.
.SH FILES
.nf
.F /dev/console
.F /dev/tty
.F /etc/utmp
.F /usr/adm/wtmp
.F /etc/ttys
.F /etc/rc.nosh
.fi
.SH "SEE ALSO"
.IR login (8), 
.IR kill (1), 
.IR sh (1), 
.IR ttys (5), 
.IR getty (8), 
.IR rc (8), 
.IR reboot (8)
.SH BUGS
The single-user shell has all privileges.