1*48834Scael.\" Copyright (c) 1980, 1991 Regents of the University of California. 2*48834Scael.\" All rights reserved. 318883Smckusick.\" 4*48834Scael.\" %sccs.include.redist.roff% 518883Smckusick.\" 6*48834Scael.\" @(#)init.8 6.4 (Berkeley) 04/29/91 7*48834Scael.\" 8*48834Scael.Dd 9*48834Scael.Dt INIT 8 10*48834Scael.Os BSD 4 11*48834Scael.Sh NAME 12*48834Scael.Nm init 13*48834Scael.Nd process control initialization 14*48834Scael.Sh SYNOPSIS 15*48834Scael.Nm init 16*48834Scael.Sh DESCRIPTION 17*48834ScaelThe 18*48834Scael.Nm init 19*48834Scaelprogram 20*48834Scaelis the last stage of the boot process. 21*48834ScaelIt normally runs the automatic reboot sequence as described in 22*48834Scael.Xr reboot 8 , 2318883Smckusickand if this succeeds, begins multi-user operation. 2418883SmckusickIf the reboot fails, it commences single user operation by giving 25*48834Scaelthe super-user a shell on the console. 26*48834ScaelThe 27*48834Scael.Nm init 28*48834Scaelprogram 29*48834Scaelmay be passed parameters 3018883Smckusickfrom the boot program to 31*48834Scaelprevent the system from going multi-user and to instead execute 32*48834Scaela single user shell with out starting the normal daemons. 33*48834ScaelThe system is then quiescent for maintenance work and may 34*48834Scaellater be made it go multi-user by killing the 35*48834Scaelthe single-user shell (with ^D). 36*48834ScaelThis 37*48834Scaelcauses 38*48834Scael.Nm init 39*48834Scaelto run the 40*48834Scael.Pa /etc/rc 41*48834Scaelstart up command file without the reboot parameter. 42*48834Scael.Pp 4318883SmckusickIn multi-user operation, 44*48834Scael.Nm init 45*48834Scaelmaintains 46*48834Scaelprocesses for the terminal ports found in the file 47*48834Scael.Xr ttys 5. 48*48834Scael.Nm Init 49*48834Scaelreads this file, and executes the command found in the second field. 50*48834ScaelThis command is usually 51*48834Scael.Xr getty 8 ; 52*48834Scael.Xr getty 53*48834Scaelopens and initializes the tty line 5418883Smckusickand 55*48834Scaelexecutes the 56*48834Scael.Xr login 57*48834Scaelprogram. 5818883SmckusickThe 59*48834Scael.Xr login 60*48834Scaelprogram, when a valid user logs in, 61*48834Scaelexectutes a shell for that user. When this shell 62*48834Scaeldies, either because the user logged out 63*48834Scaelor an abnormal termination occured (a signal), 64*48834Scaelthe 65*48834Scael.Nm init 66*48834Scaelprogram wakes up, deletes the user 67*48834Scaelfrom the 68*48834Scael.Xr utmp 5 69*48834Scaelfile of current users and records the logout in the 70*48834Scael.Xr wtmp 71*48834Scaelfile. 72*48834ScaelThe cycle is 73*48834Scaelthen restarted by 74*48834Scael.Nm init 75*48834Scaelexcuting a new 76*48834Scael.Xr getty 77*48834Scaelfor the line. 78*48834Scael.Pp 79*48834ScaelLines may be added or deleted from the 80*48834Scael.Xr ttys 81*48834Scaelfile without a reboot by sending the signal 82*48834Scael.Dv SIGHUP 83*48834Scaelto 84*48834Scael.Nm init 85*48834Scaelwith the command 86*48834Scael.Dq Li "kill -HUP 1" 87*48834ScaelUpon receipt of this signal, 88*48834Scael.Nm init 89*48834Scaelre-reads the 90*48834Scael.Xr ttys 91*48834Scaelfile. 92*48834ScaelEngaged (in use) ports 93*48834Scaelare not disturbed, 94*48834Scaeland if an engaged port has been deleted from the 95*48834Scaelfile, it will only become inactive after the engaging process has 96*48834Scaelterminated (the user has logged off). 97*48834ScaelIf a port is inactive (only a 98*48834Scael.Xr getty 99*48834Scaelor terminated processes are attached to it) 100*48834Scael.Nm init 101*48834Scaelelimiates these processes. 102*48834ScaelFor these ports and any new ports, for which a command is found 103*48834Scaelin the 104*48834Scael.Xr ttys 105*48834Scaelfile, 106*48834Scael.Nm init 107*48834Scaelexecutes a new 108*48834Scael.Xr getty . 109*48834Scael.Pp 110*48834Scael.Nm Init 11118883Smckusickwill terminate multi-user operations and resume single-user mode 112*48834Scaelif sent a terminate 113*48834Scael.Pq Dv TERM 114*48834Scaelsignal, for example, 115*48834Scael.Dq Li "kill \-TERM 1" . 11618883SmckusickIf there are processes outstanding which are deadlocked (due to 11718883Smckusickhardware or software failure), 118*48834Scael.Xr init 11918883Smckusickwill not wait for them all to die (which might take forever), but 12018883Smckusickwill time out after 30 seconds and print a warning message. 121*48834Scael.Pp 122*48834Scael.Nm Init 12318883Smckusickwill cease creating new 124*48834Scael.Xr getty Ns 's 125*48834Scaeland allow the system to slowly die away, if it is sent a terminal stop 126*48834Scael.Pq Dv TSTP 127*48834Scaelsignal, i.e. 128*48834Scael.Dq Li "kill \-TSTP 1" . 129*48834ScaelA later hangup will resume full 13018883Smckusickmulti-user operations, or a terminate will initiate a single user shell. 13118883SmckusickThis hook is used by 132*48834Scael.Xr reboot 8 13318883Smckusickand 134*48834Scael.Xr halt 8 . 135*48834Scael.Pp 136*48834ScaelThe role of 137*48834Scael.Nm init 138*48834Scaelis so critical that if it dies, the system will reboot itself 13918883Smckusickautomatically. 14018883SmckusickIf, at bootstrap time, the 141*48834Scael.Xr init 14218883Smckusickprocess cannot be located, the system will loop in user mode at location 14318883Smckusick0x13. 144*48834Scael.Sh DIAGNOSTICS 145*48834Scael.Bl -diag 146*48834Scael.It "/usr/libexec/getty \\*(eMgettyargs\\*(fP failing, sleeping." 14728561SkarelsA process being started to service a line is exiting quickly 14828561Skarelseach time it is started. 14928561SkarelsThis is often caused by a ringing or noisy terminal line. 150*48834Scael.Em "Init will sleep for 30 seconds" , 151*48834Scael.Em "then continue trying to start the process" . 152*48834Scael.Pp 153*48834Scael.It "WARNING: Something is hung (wont die); ps axl advised." 154*48834ScaelA process 15518883Smckusickis hung and could not be killed when the system was shutting down. 15618883SmckusickThis is usually caused by a process 15718883Smckusickwhich is stuck in a device driver due to a persistent device error condition. 158*48834Scael.El 159*48834Scael.Sh FILES 160*48834Scael.Bl -tag -width /var/log/wtmp -compact 161*48834Scael.It Pa /dev/console 162*48834ScaelSystem console device. 163*48834Scael.It Pa /dev/tty* 164*48834ScaelTerminal ports found in 165*48834Scael.Xr ttys . 166*48834Scael.It Pa /var/run/utmp 167*48834ScaelRecord of Current users on the system. 168*48834Scael.It Pa /var/log/wtmp 169*48834ScaelRecord of all logins and logouts. 170*48834Scael.It Pa /etc/ttys 171*48834ScaelThe terminal initialization information file. 172*48834Scael.It Pa /etc/rc 173*48834ScaelSystem startup commands. 174*48834Scael.El 175*48834Scael.Sh SEE ALSO 176*48834Scael.Xr login 1 , 177*48834Scael.Xr kill 1 , 178*48834Scael.Xr sh 1 , 179*48834Scael.Xr ttys 5 , 180*48834Scael.Xr crash 8 , 181*48834Scael.Xr getty 8 , 182*48834Scael.Xr rc 8 , 183*48834Scael.Xr reboot 8 , 184*48834Scael.Xr halt 8 , 185*48834Scael.Xr shutdown 8 186*48834Scael.Sh HISTORY 187*48834ScaelA 188*48834Scael.Nm 189*48834Scaelcommand appeared in 190*48834Scael.At v6 . 191