summaryrefslogtreecommitdiffstats
path: root/sbin/init
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>1999-06-16 20:01:19 +0000
committerru <ru@FreeBSD.org>1999-06-16 20:01:19 +0000
commitf97d9ce3bba5641b2664f8b6294c4f1a94ebafe9 (patch)
treeee4859900ac1dd788636f9f193c5c196e7648930 /sbin/init
parenta427e410f252fd837455954e644f85ba6e8bdd52 (diff)
downloadFreeBSD-src-f97d9ce3bba5641b2664f8b6294c4f1a94ebafe9.zip
FreeBSD-src-f97d9ce3bba5641b2664f8b6294c4f1a94ebafe9.tar.gz
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
Diffstat (limited to 'sbin/init')
-rw-r--r--sbin/init/init.814
-rw-r--r--sbin/init/init.c17
2 files changed, 23 insertions, 8 deletions
diff --git a/sbin/init/init.8 b/sbin/init/init.8
index 38d46ac..54e1f0d 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 6ed059f..f1cacd8 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 <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:
OpenPOWER on IntegriCloud