diff --git a/sbin/init/init.8 b/sbin/init/init.8 index 38d46ac3d72..54e1f0df5b7 100644 --- a/sbin/init/init.8 +++ b/sbin/init/init.8 @@ -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 . diff --git a/sbin/init/init.c b/sbin/init/init.c index 6ed059fa93e..f1cacd80810 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -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 @@ -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: