From owner-svn-src-all@FreeBSD.ORG Mon Apr 7 21:11:29 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D613B1C0; Mon, 7 Apr 2014 21:11:29 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 A991133F; Mon, 7 Apr 2014 21:11:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s37LBTNL050770; Mon, 7 Apr 2014 21:11:29 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s37LBTFU050769; Mon, 7 Apr 2014 21:11:29 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201404072111.s37LBTFU050769@svn.freebsd.org> From: Ed Schouten Date: Mon, 7 Apr 2014 21:11:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264237 - head/sys/kern X-SVN-Group: head 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.17 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: Mon, 07 Apr 2014 21:11:29 -0000 Author: ed Date: Mon Apr 7 21:11:29 2014 New Revision: 264237 URL: http://svnweb.freebsd.org/changeset/base/264237 Log: Clean up shutdown_nice(). Just send the right signal to init(8). Right now, init(8) cannot distinguish between an ACPI power button press or a Ctrl+Alt+Del sequence on the keyboard. This is because shutdown_nice() sends SIGINT to init(8) unconditionally, but later modifies the arguments to reboot(2) to force a certain behaviour. Instead of doing this, patch up the code to just forward the appropriate signal to userspace. SIGUSR1 and SIGUSR2 can already be used to halt the system. While there, move waittime to the function where it's used; kern_reboot(). Modified: head/sys/kern/kern_shutdown.c Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Mon Apr 7 20:44:00 2014 (r264236) +++ head/sys/kern/kern_shutdown.c Mon Apr 7 21:11:29 2014 (r264237) @@ -202,26 +202,26 @@ sys_reboot(struct thread *td, struct reb /* * Called by events that want to shut down.. e.g on a PC */ -static int shutdown_howto = 0; - void shutdown_nice(int howto) { - shutdown_howto = howto; - - /* Send a signal to init(8) and have it shutdown the world */ if (initproc != NULL) { + /* Send a signal to init(8) and have it shutdown the world. */ PROC_LOCK(initproc); - kern_psignal(initproc, SIGINT); + if (howto & RB_POWEROFF) + kern_psignal(initproc, SIGUSR2); + else if (howto & RB_HALT) + kern_psignal(initproc, SIGUSR1); + else + kern_psignal(initproc, SIGINT); PROC_UNLOCK(initproc); } else { - /* No init(8) running, so simply reboot */ + /* No init(8) running, so simply reboot. */ kern_reboot(RB_NOSYNC); } return; } -static int waittime = -1; static void print_uptime(void) @@ -295,6 +295,7 @@ void kern_reboot(int howto) { static int first_buf_printf = 1; + static int waittime = -1; #if defined(SMP) /* @@ -312,9 +313,6 @@ kern_reboot(int howto) /* We're in the process of rebooting. */ rebooting = 1; - /* collect extra flags that shutdown_nice might have set */ - howto |= shutdown_howto; - /* We are out of the debugger now. */ kdb_active = 0;