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().
This commit is contained in:
parent
4e1ad9d117
commit
912d59378b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=264237
@ -202,26 +202,26 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user