summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2010-10-14 23:48:58 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2010-10-14 23:48:58 +0000
commit0eb79fb1ef6565077988898a390c4aa269bfe0ea (patch)
treef40a15265b9741fa6fa7d37ed205c9d63f31c14e /sbin
parent9c9cf5e82e30158f5b322404363bb7ad65ffbe6d (diff)
add a SIGQUIT handler that does the same as USR1 and USR2, except it
reboots the machine instead just halting or powering down. diff from Jonathan Matthew manpage tweaks from jmc@ ok deraadt@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/init/init.831
-rw-r--r--sbin/init/init.c22
2 files changed, 37 insertions, 16 deletions
diff --git a/sbin/init/init.8 b/sbin/init/init.8
index 25ad38ec2b1..4decc2abb05 100644
--- a/sbin/init/init.8
+++ b/sbin/init/init.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: init.8,v 1.42 2010/09/19 20:59:20 jmc Exp $
+.\" $OpenBSD: init.8,v 1.43 2010/10/14 23:48:57 dlg Exp $
.\" $NetBSD: init.8,v 1.6 1995/03/18 14:56:31 cgd Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
@@ -33,7 +33,7 @@
.\"
.\" @(#)init.8 8.6 (Berkeley) 5/26/95
.\"
-.Dd $Mdocdate: September 19 2010 $
+.Dd $Mdocdate: October 14 2010 $
.Dt INIT 8
.Os
.Sh NAME
@@ -213,18 +213,25 @@ and
.Nm
will terminate multi-user operations, kill all
.Xr getty 8 ,
-run
-.Pa /etc/rc.shutdown ,
-and halt the machine if user-defined signal 1
-.Pq Dv USR1
-or user-defined signal 2
-.Pq Dv USR2
-is received.
+and run
.Pa /etc/rc.shutdown
-can specify that a powerdown is requested.
-Alternatively,
+if a user-defined signal 1
+.Pq Dv USR1 ,
+user-defined signal 2
+.Pq Dv USR2 ,
+or
+.Dv QUIT
+signal is received.
+Following this,
+.Dv USR1
+will halt the system;
.Dv USR2
-specifically requests a powerdown.
+will request a powerdown; and
+.Dv QUIT
+will cause a reboot.
+.Pa /etc/rc.shutdown
+can specify that a powerdown is requested instead of the action
+specified by the signal.
.Pp
The role of
.Nm
diff --git a/sbin/init/init.c b/sbin/init/init.c
index ee2a169a15e..2b76f934ace 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.43 2010/09/29 13:23:37 dcoppa Exp $ */
+/* $OpenBSD: init.c,v 1.44 2010/10/14 23:48:57 dlg Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
@@ -107,6 +107,7 @@ state_func_t multi_user(void);
state_func_t clean_ttys(void);
state_func_t catatonia(void);
state_func_t death(void);
+state_func_t do_reboot(void);
state_func_t hard_death(void);
state_func_t nice_death(void);
@@ -231,12 +232,12 @@ main(int argc, char *argv[])
handle(badsys, SIGSYS, 0);
handle(disaster, SIGABRT, SIGFPE, SIGILL, SIGSEGV,
SIGBUS, SIGXCPU, SIGXFSZ, 0);
- handle(transition_handler, SIGHUP, SIGTERM, SIGTSTP, SIGUSR1,
- SIGUSR2, 0);
+ handle(transition_handler, SIGHUP, SIGQUIT, SIGTERM, SIGTSTP,
+ SIGUSR1, SIGUSR2, 0);
handle(alrm_handler, SIGALRM, 0);
sigfillset(&mask);
delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS,
- SIGXCPU, SIGXFSZ, SIGHUP, SIGTERM, SIGUSR1, SIGUSR2,
+ SIGXCPU, SIGXFSZ, SIGHUP, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2,
SIGTSTP, SIGALRM, 0);
sigprocmask(SIG_SETMASK, &mask, NULL);
memset(&sa, 0, sizeof sa);
@@ -1133,6 +1134,9 @@ transition_handler(int sig)
case SIGHUP:
requested_transition = clean_ttys;
break;
+ case SIGQUIT:
+ requested_transition = do_reboot;
+ break;
case SIGTERM:
requested_transition = death;
break;
@@ -1277,6 +1281,16 @@ alrm_handler(int sig)
int death_howto = RB_HALT;
/*
+ * Reboot the system.
+ */
+state_func_t
+do_reboot(void)
+{
+ death_howto = RB_AUTOBOOT;
+ return nice_death();
+}
+
+/*
* Bring the system down nicely, then we must powerdown because something
* is very wrong.
*/