Init(8) will halt the system if sent USR1 signal,

or halt and turn the power off if sent SIGUSR2.

PR:		5451
Submitted by:	Leif Neland <leifn@image.dk>
Reworked by:	ru
Reviewed by:	-hackers
This commit is contained in:
Ruslan Ermilov 1999-06-16 20:01:19 +00:00
parent 23fc6cddce
commit a0a549c7fd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=47962
2 changed files with 23 additions and 8 deletions

View File

@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)init.8 8.3 (Berkeley) 4/18/94
.\" $Id: init.8,v 1.12 1998/07/06 06:56:07 charnier Exp $
.\" $Id: init.8,v 1.13 1998/12/16 16:50:12 ghelmer Exp $
.\"
.Dd April 18, 1994
.Dt INIT 8
@ -252,6 +252,14 @@ signal, i.e.
This is useful for shutting the machine down cleanly from inside the kernel
or from X when the machine appears to be hung.
.Pp
.Nm Init
will do the same, except it will shutdown the machine if sent
the user defined signal 1
.Pq Dv USR1 ,
or will shutdown and turn the power off (if hardware permits) if sent
the user defined signal 2
.Pq Dv USR2 .
.Pp
When shutting down the machine,
.Nm
will try to run the
@ -286,7 +294,7 @@ that is stuck in a device driver because of
a persistent device error condition.
.El
.Sh FILES
.Bl -tag -width /var/log/wtmp -compact
.Bl -tag -width /etc/rc.shutdown -compact
.It Pa /dev/console
system console device
.It Pa /dev/tty*
@ -318,7 +326,7 @@ system shutdown commands
.Xr shutdown 8 ,
.Xr sysctl 8
.Sh HISTORY
A
An
.Nm
command appeared in
.At v6 .

View File

@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 7/15/93";
#endif
static const char rcsid[] =
"$Id: init.c,v 1.30 1998/07/06 06:56:08 charnier Exp $";
"$Id: init.c,v 1.31 1998/07/22 05:45:11 phk Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -132,6 +132,7 @@ enum { AUTOBOOT, FASTBOOT } runcom_mode = AUTOBOOT;
#define TRUE 1
int Reboot = FALSE;
int howto = RB_AUTOBOOT;
int devfs;
@ -259,11 +260,13 @@ main(argc, argv)
handle(badsys, SIGSYS, 0);
handle(disaster, SIGABRT, SIGFPE, SIGILL, SIGSEGV,
SIGBUS, SIGXCPU, SIGXFSZ, 0);
handle(transition_handler, SIGHUP, SIGINT, SIGTERM, SIGTSTP, 0);
handle(transition_handler, SIGHUP, SIGINT, SIGTERM, SIGTSTP,
SIGUSR1, SIGUSR2, 0);
handle(alrm_handler, SIGALRM, 0);
sigfillset(&mask);
delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS,
SIGXCPU, SIGXFSZ, SIGHUP, SIGINT, SIGTERM, SIGTSTP, SIGALRM, 0);
SIGXCPU, SIGXFSZ, SIGHUP, SIGINT, SIGTERM, SIGTSTP, SIGALRM,
SIGUSR1, SIGUSR2, 0);
sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
@ -594,11 +597,11 @@ single_user()
setsecuritylevel(0);
if (Reboot) {
/* Instead of going single user, let's halt the machine */
/* Instead of going single user, let's reboot the machine */
sync();
alarm(2);
pause();
reboot(RB_AUTOBOOT);
reboot(howto);
_exit(0);
}
@ -1238,6 +1241,10 @@ transition_handler(sig)
case SIGHUP:
requested_transition = clean_ttys;
break;
case SIGUSR2:
howto = RB_POWEROFF;
case SIGUSR1:
howto |= RB_HALT;
case SIGINT:
Reboot = TRUE;
case SIGTERM: