svn commit: r324987 - head/sbin/init

Warner Losh imp at FreeBSD.org
Wed Oct 25 15:30:41 UTC 2017


Author: imp
Date: Wed Oct 25 15:30:40 2017
New Revision: 324987
URL: https://svnweb.freebsd.org/changeset/base/324987

Log:
  Implement power cycle in init.
  
  If SIGWINCH is received, then halt with power cycle.
  
  Sponsored by: Netflix

Modified:
  head/sbin/init/init.8
  head/sbin/init/init.c

Modified: head/sbin/init/init.8
==============================================================================
--- head/sbin/init/init.8	Wed Oct 25 15:30:35 2017	(r324986)
+++ head/sbin/init/init.8	Wed Oct 25 15:30:40 2017	(r324987)
@@ -286,6 +286,7 @@ as follows:
 .It Sy "Run-level	Signal	Action"
 .It Cm 0 Ta Dv SIGUSR1 Ta "Halt"
 .It Cm 0 Ta Dv SIGUSR2 Ta "Halt and turn the power off"
+.It Cm 0 Ta Dv SIGWINCH Ta "Halt and turn the power off and then back on"
 .It Cm 1 Ta Dv SIGTERM Ta "Go to single-user mode"
 .It Cm 6 Ta Dv SIGINT Ta "Reboot the machine"
 .It Cm c Ta Dv SIGTSTP Ta "Block further logins"

Modified: head/sbin/init/init.c
==============================================================================
--- head/sbin/init/init.c	Wed Oct 25 15:30:35 2017	(r324986)
+++ head/sbin/init/init.c	Wed Oct 25 15:30:40 2017	(r324987)
@@ -305,12 +305,12 @@ invalid:
 	handle(disaster, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGXCPU,
 	    SIGXFSZ, 0);
 	handle(transition_handler, SIGHUP, SIGINT, SIGEMT, SIGTERM, SIGTSTP,
-	    SIGUSR1, SIGUSR2, 0);
+	    SIGUSR1, SIGUSR2, SIGWINCH, 0);
 	handle(alrm_handler, SIGALRM, 0);
 	sigfillset(&mask);
 	delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS,
 	    SIGXCPU, SIGXFSZ, SIGHUP, SIGINT, SIGEMT, SIGTERM, SIGTSTP,
-	    SIGALRM, SIGUSR1, SIGUSR2, 0);
+	    SIGALRM, SIGUSR1, SIGUSR2, SIGWINCH, 0);
 	sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
 	sigemptyset(&sa.sa_mask);
 	sa.sa_flags = 0;
@@ -1557,8 +1557,9 @@ transition_handler(int sig)
 		    current_state == clean_ttys || current_state == catatonia)
 			requested_transition = clean_ttys;
 		break;
+	case SIGWINCH:
 	case SIGUSR2:
-		howto = RB_POWEROFF;
+		howto = sig == SIGUSR2 ? RB_POWEROFF : RB_POWERCYCLE;
 	case SIGUSR1:
 		howto |= RB_HALT;
 	case SIGINT:


More information about the svn-src-all mailing list