xref: /openbsd/lib/libc/sys/reboot.2 (revision 91f110e0)
1.\"	$OpenBSD: reboot.2,v 1.16 2014/01/21 03:15:45 schwarze Exp $
2.\"	$NetBSD: reboot.2,v 1.5 1995/02/27 12:36:02 cgd Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)reboot.2	8.1 (Berkeley) 6/4/93
32.\"
33.Dd $Mdocdate: January 21 2014 $
34.Dt REBOOT 2
35.Os
36.Sh NAME
37.Nm reboot
38.Nd reboot system or halt processor
39.Sh SYNOPSIS
40.Fd #include <unistd.h>
41.Fd #include <sys/reboot.h>
42.Ft int
43.Fn reboot "int howto"
44.Sh DESCRIPTION
45.Fn reboot
46reboots the system.
47Only the superuser may reboot a machine on demand.
48However, a reboot is invoked
49automatically in the event of unrecoverable system failures.
50.Pp
51.Fa howto
52is a mask of options; the system call interface allows the following
53options, defined in the include file
54.In sys/reboot.h ,
55to be passed
56to the new kernel or the new bootstrap and init programs.
57.Bl -tag -width RB_INITNAMEA
58.It Dv RB_AUTOBOOT
59The default, causing the system to reboot in its usual fashion.
60.It Dv RB_ASKNAME
61Interpreted by the bootstrap program itself, causing it to
62prompt on the console as to what file should be booted.
63Normally, the system is booted from the file
64.Dq Em xx Ns (0,0)bsd ,
65where
66.Em xx
67is the default disk name,
68without prompting for the file name.
69.It Dv RB_DFLTROOT
70Use the compiled in root device.
71Normally, the system uses the device from which it was booted
72as the root device if possible.
73(The default behavior is dependent on the ability of the bootstrap program
74to determine the drive from which it was loaded, which is not possible
75on all systems.)
76.It Dv RB_DUMP
77Dump kernel memory before rebooting; see
78.Xr savecore 8
79for more information.
80.It Dv RB_HALT
81The processor is simply halted; no reboot takes place.
82.It Dv RB_POWERDOWN
83If used in conjunction with
84.Dv RB_HALT ,
85and if the system hardware supports the function, the system will be
86powered off.
87.It Dv RB_USERREQ
88By default, the system will halt if
89.Fn reboot
90is called during startup (before the system has finished autoconfiguration),
91even if
92.Dv RB_HALT
93is not specified.
94This is because
95.Xr panic 9 Ns s
96during startup will probably just repeat on the next boot.
97Use of this option implies that the user has requested the action
98specified (for example, using the
99.Xr ddb 4
100.Ic boot reboot
101command),
102so the system will reboot if a halt is not explicitly requested.
103.It Dv RB_INITNAME
104An option allowing the specification of an init program (see
105.Xr init 8 )
106other than
107.Pa /sbin/init
108to be run when the system reboots.
109This switch is not currently available.
110.It Dv RB_KDB
111Load the symbol table and enable a built-in debugger in the system.
112This option will have no useful function if the kernel is not configured
113for debugging.
114Several other options have different meaning if combined
115with this option, although their use may not be possible via the
116.Fn reboot
117call.
118See
119.Xr ddb 4
120for more information.
121.It Dv RB_NOSYNC
122Normally, the disks are sync'd (see
123.Xr sync 8 )
124before the processor is halted or rebooted.
125This option may be useful if file system changes have been made manually
126or if the processor is on fire.
127.It Dv RB_RDONLY
128Initially mount the root file system read-only.
129This is currently the default, and this option has been deprecated.
130.It Dv RB_SINGLE
131Normally, the reboot procedure involves an automatic disk consistency
132check and then multi-user operations.
133.Dv RB_SINGLE
134prevents this, booting the system with a single-user shell
135on the console.
136.Dv RB_SINGLE
137is actually interpreted by the
138.Xr init 8
139program in the newly booted system.
140.Pp
141When no options are given (i.e.,
142.Dv RB_AUTOBOOT
143is used), the system is
144rebooted from file ``bsd'' in the root file system of unit 0
145of a disk chosen in a processor specific way.
146An automatic consistency check of the disks is normally performed
147(see
148.Xr fsck 8 ) .
149.El
150.Sh RETURN VALUES
151If successful, this call never returns.
152Otherwise, a \-1 is returned and an error is returned in the global
153variable
154.Va errno .
155.Sh ERRORS
156.Bl -tag -width Er
157.It Bq Er EPERM
158The caller is not the superuser.
159.El
160.Sh SEE ALSO
161.Xr ddb 4 ,
162.Xr crash 8 ,
163.Xr halt 8 ,
164.Xr init 8 ,
165.Xr reboot 8 ,
166.Xr savecore 8 ,
167.Xr boot 9 ,
168.Xr panic 9
169.Sh HISTORY
170The
171.Fn reboot
172system call finally appeared in
173.Bx 4.0 .
174.Sh BUGS
175Not all platforms support all possible arguments.
176