From owner-svn-src-all@freebsd.org Wed Oct 25 15:30:41 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D5ABE4D796; Wed, 25 Oct 2017 15:30:41 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3931572166; Wed, 25 Oct 2017 15:30:41 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PFUelx020586; Wed, 25 Oct 2017 15:30:40 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PFUeGv020584; Wed, 25 Oct 2017 15:30:40 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201710251530.v9PFUeGv020584@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 25 Oct 2017 15:30:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324987 - head/sbin/init X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sbin/init X-SVN-Commit-Revision: 324987 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 15:30:41 -0000 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: