1.\" $NetBSD: boot.9,v 1.2 1996/09/24 07:01:26 ghudson Exp $ 2.\" 3.\" Copyright (c) 1997 4.\" Mike Pritchard. All rights reserved. 5.\" 6.\" Copyright (c) 1994 Christopher G. Demetriou 7.\" All rights reserved. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by Christopher G. Demetriou 20.\" for the NetBSD Project. 21.\" 3. The name of the author may not be used to endorse or promote products 22.\" derived from this software without specific prior written permission 23.\" 24.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 28.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 29.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" 35.\" $FreeBSD$ 36.\" 37.Dd Sept 23, 2021 38.Dt KERN_REBOOT 9 39.Os 40.Sh NAME 41.Nm kern_reboot 42.Nd halt or reboot the system 43.Sh SYNOPSIS 44.In sys/types.h 45.In sys/systm.h 46.In sys/reboot.h 47.Ft void 48.Fn kern_reboot "int howto" 49.In sys/eventhandler.h 50.Fn EVENTHANDLER_REGISTER "shutdown_pre_sync" "shutdown_fn" "private" "priority" 51.Fn EVENTHANDLER_REGISTER "shutdown_post_sync" "shutdown_fn" "private" "priority" 52.Fn EVENTHANDLER_REGISTER "shutdown_final" "shutdown_fn" "private" "priority" 53.Sh DESCRIPTION 54The 55.Fn kern_reboot 56function handles final system shutdown, and either halts or reboots 57the system. 58The exact action to be taken is determined by the flags passed in 59.Fa howto 60and by whether or not the system has finished autoconfiguration. 61.Pp 62If the system has finished autoconfiguration, 63.Fn kern_reboot 64does the following: 65.Bl -enum -offset indent 66.It 67If this is the first invocation of 68.Fn kern_reboot 69and the 70.Dv RB_NOSYNC 71flag is not set in 72.Fa howto , 73syncs and unmounts the system disks by calling 74.Xr vfs_unmountall 9 . 75.It 76Disables interrupts. 77.It 78If rebooting after a crash (i.e., if 79.Dv RB_DUMP 80is set in 81.Fa howto , 82but 83.Dv RB_HALT 84is not), saves a system crash dump. 85.It 86Runs any shutdown hooks previously registered. 87.It 88Prints a message indicating that the system is about to be halted 89or rebooted. 90.It 91If 92.Dv RB_HALT 93is set in 94.Fa howto , 95halts the system. 96Otherwise, reboots the system. 97.El 98.Pp 99If the system has not finished autoconfiguration, 100.Fn kern_reboot 101runs any shutdown hooks previously registered, 102prints a message, and halts the system. 103.Sh RETURN VALUES 104The 105.Fn kern_reboot 106function does not return. 107.Sh SEE ALSO 108.Xr reboot 2 109.Xr EVENTHANDLER 9 110.Xr vfs_unmountall 9 111