Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Oct 2017 15:30:40 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324987 - head/sbin/init
Message-ID:  <201710251530.v9PFUeGv020584@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710251530.v9PFUeGv020584>