summaryrefslogtreecommitdiffstats
path: root/sbin/init/init.c
diff options
context:
space:
mode:
authornate <nate@FreeBSD.org>1994-08-27 21:32:01 +0000
committernate <nate@FreeBSD.org>1994-08-27 21:32:01 +0000
commit398581a79d2c3d05edaf080a2a7a58f3d6ecbece (patch)
tree6a15dfa4b4604143e9ce946963e29f5c77bb89e9 /sbin/init/init.c
parent991b08fc7adff13fbe1b7b06a898a818433eca4e (diff)
downloadFreeBSD-src-398581a79d2c3d05edaf080a2a7a58f3d6ecbece.zip
FreeBSD-src-398581a79d2c3d05edaf080a2a7a58f3d6ecbece.tar.gz
Bring in my changes from the 1.1 init.bsdi which causes a reboot (was a
halt before) if init is sent an interrupt signal. This is necessary for <CTL><ALT><DEL> to do the right thing if enabled.
Diffstat (limited to 'sbin/init/init.c')
-rw-r--r--sbin/init/init.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index cd5914a..413fa5e 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -59,6 +59,7 @@ static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 7/15/93";
#include <time.h>
#include <ttyent.h>
#include <unistd.h>
+#include <sys/reboot.h>
#ifdef __STDC__
#include <stdarg.h>
@@ -114,6 +115,7 @@ state_func_t catatonia __P((void));
state_func_t death __P((void));
enum { AUTOBOOT, FASTBOOT } runcom_mode = AUTOBOOT;
+int reboot = FALSE;
void transition __P((state_t));
state_t requested_transition = runcom;
@@ -229,11 +231,11 @@ main(argc, argv)
handle(badsys, SIGSYS, 0);
handle(disaster, SIGABRT, SIGFPE, SIGILL, SIGSEGV,
SIGBUS, SIGXCPU, SIGXFSZ, 0);
- handle(transition_handler, SIGHUP, SIGTERM, SIGTSTP, 0);
+ handle(transition_handler, SIGHUP, SIGINT, SIGTERM, SIGTSTP, 0);
handle(alrm_handler, SIGALRM, 0);
sigfillset(&mask);
delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS,
- SIGXCPU, SIGXFSZ, SIGHUP, SIGTERM, SIGTSTP, SIGALRM, 0);
+ SIGXCPU, SIGXFSZ, SIGHUP, SIGINT, SIGTERM, SIGTSTP, SIGALRM, 0);
sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
@@ -560,6 +562,15 @@ single_user()
if (getsecuritylevel() > 0)
setsecuritylevel(0);
+ if (reboot) {
+ /* Instead of going single user, let's halt the machine */
+ sync();
+ alarm(2);
+ pause();
+ reboot(RB_AUTOBOOT);
+ _exit(0);
+ }
+
if ((pid = fork()) == 0) {
/*
* Start the single user session.
@@ -1129,6 +1140,8 @@ transition_handler(sig)
case SIGHUP:
requested_transition = clean_ttys;
break;
+ case SIGINT:
+ reboot = TRUE;
case SIGTERM:
requested_transition = death;
break;
OpenPOWER on IntegriCloud