svn commit: r264237 - head/sys/kern
Ed Schouten
ed at FreeBSD.org
Mon Apr 7 21:11:29 UTC 2014
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 <CTL><ALT><DEL> 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;
More information about the svn-src-head
mailing list