[9] | 1 | .TH INIT 8
|
---|
| 2 | .SH NAME
|
---|
| 3 | init \- grandparent of all processes
|
---|
| 4 | .SH DESCRIPTION
|
---|
| 5 | The first program started by MINIX 3 is
|
---|
| 6 | .BR init .
|
---|
| 7 | The actions performed by
|
---|
| 8 | .B init
|
---|
| 9 | can be summarized by this pseudo shell program:
|
---|
| 10 | .RS
|
---|
| 11 | .nf
|
---|
| 12 | .if t .ft C
|
---|
| 13 |
|
---|
| 14 | # Open 0, 1, 2.
|
---|
| 15 | exec </dev/null >/dev/log 2>&1
|
---|
| 16 |
|
---|
| 17 | # Run the system initialization script.
|
---|
| 18 | sh /etc/rc $bootopts
|
---|
| 19 |
|
---|
| 20 | >/etc/utmp
|
---|
| 21 | echo reboot >>/usr/adm/wtmp
|
---|
| 22 |
|
---|
| 23 | while :; do
|
---|
| 24 | # Wait for a process to exit, but don't always block.
|
---|
| 25 | wait
|
---|
| 26 |
|
---|
| 27 | # Record logout. (Not in this dumb way, of course.)
|
---|
| 28 | if "pid is in my tables" $pid
|
---|
| 29 | then
|
---|
| 30 | echo "logout $pid" >/etc/utmp
|
---|
| 31 | echo "logout $pid" >>/usr/adm/wtmp
|
---|
| 32 | fi
|
---|
| 33 |
|
---|
| 34 | # Start a new session.
|
---|
| 35 | while read line type getty init
|
---|
| 36 | do
|
---|
| 37 | if idle $line
|
---|
| 38 | then
|
---|
| 39 | $init ... <$tty >$tty
|
---|
| 40 | $getty <$tty >$tty 2>&1 &
|
---|
| 41 | pid=$!
|
---|
| 42 | "add pid to tables" $pid
|
---|
| 43 | echo "login $line $pid" >/etc/utmp
|
---|
| 44 | echo "login $line $pid" >>/usr/adm/wtmp
|
---|
| 45 | fi
|
---|
| 46 | done < /dev/ttytab
|
---|
| 47 | done
|
---|
| 48 |
|
---|
| 49 | .if t .ft R
|
---|
| 50 | .fi
|
---|
| 51 | .RE
|
---|
| 52 | The first action of
|
---|
| 53 | .B init
|
---|
| 54 | is to run
|
---|
| 55 | .B /etc/rc
|
---|
| 56 | to initialize the system as described in
|
---|
| 57 | .BR boot (8).
|
---|
| 58 | .B Init
|
---|
| 59 | then enters its main loop where it waits for processes to exit, and starts
|
---|
| 60 | processes on each enabled terminal line. The file
|
---|
| 61 | .B /etc/ttytab
|
---|
| 62 | contains a list of terminal devices, their terminal types, the program to
|
---|
| 63 | execute on them to allow one to login (usually
|
---|
| 64 | .BR getty (8)),
|
---|
| 65 | and the program to execute first to initialize the line (usually
|
---|
| 66 | .BR stty (1)).
|
---|
| 67 | These fields may be left out to indicate that a line is disabled or that
|
---|
| 68 | initialization is not necessary. The commands are searched using the path
|
---|
| 69 | .BR /sbin:/bin:/usr/sbin:/usr/bin .
|
---|
| 70 | .PP
|
---|
| 71 | .B Init
|
---|
| 72 | accepts several signals that must be sent to process id 1. (It is the first
|
---|
| 73 | process, so natually its process id is 1.) The signals are:
|
---|
| 74 | .TP
|
---|
| 75 | .B SIGHUP
|
---|
| 76 | When receiving a hangup signal,
|
---|
| 77 | .B init
|
---|
| 78 | will forget about errors and rescan
|
---|
| 79 | .B ttytab
|
---|
| 80 | for processes to execute.
|
---|
| 81 | .B Init
|
---|
| 82 | normally rescans
|
---|
| 83 | .B ttytab
|
---|
| 84 | each time it feels the need to respawn a process, so the hangup signal is only
|
---|
| 85 | needed if a line has been shut down, or after a terminate signal. Note
|
---|
| 86 | that after turning a line off you will have to kill the process running on
|
---|
| 87 | that line manually,
|
---|
| 88 | .B init
|
---|
| 89 | doesn't do that for you.
|
---|
| 90 | .TP
|
---|
| 91 | .B SIGTERM
|
---|
| 92 | Normally sent by programs that halt or reboot MINIX 3. Causes
|
---|
| 93 | .B init
|
---|
| 94 | to stop spawning new processes.
|
---|
| 95 | .TP
|
---|
| 96 | .B SIGABRT
|
---|
| 97 | Sent by the keyboard driver when the
|
---|
| 98 | .B CTRL-ALT-DEL
|
---|
| 99 | key combination is typed. Causes
|
---|
| 100 | .B init
|
---|
| 101 | to run the
|
---|
| 102 | .B shutdown
|
---|
| 103 | command. A second abort signal makes
|
---|
| 104 | .B init
|
---|
| 105 | halt the system directly with a system call. The keyboard driver halts the
|
---|
| 106 | system, without a sync, after the third CTRL-ALT-DEL.
|
---|
| 107 | .SS "MINIX 3 vs. Minix-vmd"
|
---|
| 108 | There are a few differences between standard MINIX 3 and Minix-vmd on how
|
---|
| 109 | .B init
|
---|
| 110 | is run. The
|
---|
| 111 | .B /etc/rc
|
---|
| 112 | file is executed under standard MINIX 3 with input connected to
|
---|
| 113 | .BR /dev/console ,
|
---|
| 114 | but under Minix-vmd this is still
|
---|
| 115 | .BR /dev/null .
|
---|
| 116 | This means that under Minix-vmd processes must be reconnected to
|
---|
| 117 | .B /dev/console
|
---|
| 118 | with the
|
---|
| 119 | .BR intr (8)
|
---|
| 120 | program if they need user interaction.
|
---|
| 121 | Minix-vmd passes the value of the
|
---|
| 122 | .B bootopts
|
---|
| 123 | boot variable to /etc/rc. Standard MINIX 3 does not.
|
---|
| 124 | .SH FILES
|
---|
| 125 | .TP 25n
|
---|
| 126 | .B /etc/ttytab
|
---|
| 127 | List of terminals devices.
|
---|
| 128 | .TP
|
---|
| 129 | .B /etc/utmp
|
---|
| 130 | List of currently logged in users.
|
---|
| 131 | .TP
|
---|
| 132 | .B /usr/adm/wtmp
|
---|
| 133 | Login/logout history.
|
---|
| 134 | .SH "SEE ALSO"
|
---|
| 135 | .BR ttytab (5),
|
---|
| 136 | .BR utmp (5),
|
---|
| 137 | .BR getty (8),
|
---|
| 138 | .BR stty (1),
|
---|
| 139 | .BR boot (8).
|
---|
| 140 | .SH AUTHOR
|
---|
| 141 | Kees J. Bot (kjb@cs.vu.nl)
|
---|