'\"macro stdmacro
.if n .pH g1a.rc0 @(#)rc0	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} rc0 1M "Essential Utilities" "\&"
.if \nX=1 .ds x} rc0 1M "Essential Utilities"
.if \nX=2 .ds x} rc0 1M "" "\&"
.if \nX=3 .ds x} rc0 "" "" "\&"
.TH \*(x}
.SH NAME
\f4rc0\f1 \- run commands performed to stop the operating system
.SH SYNOPSIS
\f4/sbin/rc0\f1
.SH DESCRIPTION
This file is executed at each system state change that needs to have the
system in an inactive state.
It is responsible for those actions that bring the system to a quiescent state,
traditionally called ``shutdown''.
.PP
There are three system states that require this procedure.
They are state \f40\f1 (the system halt state),
state \f45\f1 (the firmware state), and state \f46\f1
(the reboot state).
Whenever a change to one of these states occurs, the
\f4rc0\f1
procedure is run.
The entry in
\f4/sbin/inittab\f1
might read:
.sp
.RS
\f4s0:056:wait:/sbin/rc0 >/dev/console 2>&1 </dev/console\f1
.br
.RE
.PP
Some of the actions performed by
\f4rc0\f1
are carried out by files in the directory
\f4/usr/sbin/shutdown.d\f1.
and files beginning with \f4K\f1 in \f4/sbin/rc0.d\f1.
These files are executed in ASCII order
(see FILES below for more information),
terminating some system service.
The combination of commands in
\f4rc0\f1
and files in
\f4/usr/sbin/shutdown.d\f1
and \f4/sbin/rc0.d\f1
determines how the system is shut down.
.PP
The recommended sequence for
\f4rc0\f1
is:
.PP
Stop System Services and Daemons.
.sp
.RS
Various system services
(such as 3BNET Local Area Network or LP Spooler) are gracefully
terminated.
.sp
When new services are added that should be terminated when the system is shut
down, the appropriate files are installed in
\f4/usr/sbin/shutdown.d\f1
and \f4/sbin/rc0.d\f1.
.RE
.PP
Terminate Processes
.sp
.RS
\f4SIGTERM\f1 signals are sent to all running processes by
\f4killall\fP(1M).
Processes stop themselves cleanly if sent \f4SIGTERM\f1.
.RE
.PP
Kill Processes
.sp
.RS
\f4SIGKILL\f1 signals are sent to all remaining processes; no process can resist
\f4SIGKILL\f1.
.sp
At this point the only processes left are those associated with
\f4rc0\f1
and processes \f40\f1 and \f41\f1, which are special to the operating system.
.RE
.PP
Unmount All File Systems
.sp
.RS
Only the root file system (\f4/\f1) remains mounted.
.RE
.PP
Depending on which system state the systems end up in (\f40\f1, \f45\f1, or \f46\f1),
the entries in
\f4/sbin/inittab\f1
will direct what happens next.
If the
\f4/sbin/inittab\f1
has not defined any other actions to be performed as in the case of system state \f40\f1,
then the operating system will have nothing to do.
It should not be possible to get the system's attention.
The only thing that can be done is to turn off the power or possibly get
the attention of a firmware monitor.
The command can be used only by the super-user.
.SH FILES
The execution by
\f4/usr/bin/sh\f1
of any files in
\f4/usr/sbin/shutdown.d\f1
occurs in ASCII sort-sequence order.
See \f4rc2\f1(1M) for more information.
.SH SEE ALSO
\f4killall\fP(1M),
\f4rc2\fP(1M),
\f4shutdown\fP(1M).
.Ee
