OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / man2 / reboot.2
1 .\" Copyright (c) 1998 Andries Brouwer (aeb@cwi.nl), 24 September 1998
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
26 .\"     Added notes on capability requirements
27 .\"
28 .TH REBOOT 2 2015-02-01 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 reboot \- reboot or enable/disable Ctrl-Alt-Del
31 .SH SYNOPSIS
32 /* For libc4 and libc5 the library call and the system call
33    are identical, and since kernel version 2.1.30 there are
34    symbolic names LINUX_REBOOT_* for the constants and a
35    fourth argument to the call: */
36 .sp
37 .B #include <unistd.h>
38 .br
39 .B #include <linux/reboot.h>
40 .sp
41 .BI "int reboot(int " magic ", int " magic2 ", int " cmd ", void *" arg );
42 .sp
43 /* Under glibc some of the constants involved have gotten
44    symbolic names RB_*, and the library call is a 1-argument
45    wrapper around the 3-argument system call: */
46 .sp
47 .B #include <unistd.h>
48 .br
49 .B #include <sys/reboot.h>
50 .sp
51 .BI "int reboot(int " cmd );
52 .SH DESCRIPTION
53 The
54 .BR reboot ()
55 call reboots the system, or enables/disables the reboot keystroke
56 (abbreviated CAD, since the default is Ctrl-Alt-Delete;
57 it can be changed using
58 .BR loadkeys (1)).
59 .PP
60 This system call will fail (with
61 .BR EINVAL )
62 unless
63 .I magic
64 equals
65 .B LINUX_REBOOT_MAGIC1
66 (that is, 0xfee1dead) and
67 .I magic2
68 equals
69 .B LINUX_REBOOT_MAGIC2
70 (that is, 672274793).
71 However, since 2.1.17 also
72 .B LINUX_REBOOT_MAGIC2A
73 (that is, 85072278)
74 and since 2.1.97 also
75 .B LINUX_REBOOT_MAGIC2B
76 (that is, 369367448)
77 and since 2.5.71 also
78 .B LINUX_REBOOT_MAGIC2C
79 (that is, 537993216)
80 are permitted as values for
81 .IR magic2 .
82 (The hexadecimal values of these constants are meaningful.)
83
84 The
85 .I cmd
86 argument can have the following values:
87 .TP
88 .B LINUX_REBOOT_CMD_CAD_OFF
89 .RB ( RB_DISABLE_CAD ,
90 0).
91 CAD is disabled.
92 This means that the CAD keystroke will cause a
93 .B SIGINT
94 signal to be
95 sent to init (process 1), whereupon this process may decide upon a
96 proper action (maybe: kill all processes, sync, reboot).
97 .TP
98 .B LINUX_REBOOT_CMD_CAD_ON
99 .RB ( RB_ENABLE_CAD ,
100 0x89abcdef).
101 CAD is enabled.
102 This means that the CAD keystroke will immediately cause
103 the action associated with
104 .BR LINUX_REBOOT_CMD_RESTART .
105 .TP
106 .B LINUX_REBOOT_CMD_HALT
107 .RB ( RB_HALT_SYSTEM ,
108 0xcdef0123; since Linux 1.1.76).
109 The message "System halted." is printed, and the system is halted.
110 Control is given to the ROM monitor, if there is one.
111 If not preceded by a
112 .BR sync (2),
113 data will be lost.
114 .TP
115 .BR LINUX_REBOOT_CMD_KEXEC
116 .RB ( RB_KEXEC ,
117 0x45584543, since Linux 2.6.13).
118 Execute a kernel that has been loaded earlier with
119 .BR kexec_load (2).
120 This option is available only if the kernel was configured with
121 .BR CONFIG_KEXEC .
122 .TP
123 .B LINUX_REBOOT_CMD_POWER_OFF
124 .RB ( RB_POWER_OFF ,
125 0x4321fedc; since Linux 2.1.30).
126 The message "Power down." is printed, the system is stopped,
127 and all power is removed from the system, if possible.
128 If not preceded by a
129 .BR sync (2),
130 data will be lost.
131 .TP
132 .B LINUX_REBOOT_CMD_RESTART
133 .RB ( RB_AUTOBOOT ,
134 0x1234567).
135 The message "Restarting system." is printed, and a default
136 restart is performed immediately.
137 If not preceded by a
138 .BR sync (2),
139 data will be lost.
140 .TP
141 .B LINUX_REBOOT_CMD_RESTART2
142 (0xa1b2c3d4; since Linux 2.1.30).
143 The message "Restarting system with command \(aq%s\(aq" is printed,
144 and a restart (using the command string given in
145 .IR arg )
146 is performed immediately.
147 If not preceded by a
148 .BR sync (2),
149 data will be lost.
150 .TP
151 .BR LINUX_REBOOT_CMD_SW_SUSPEND
152 .RB ( RB_SW_SUSPEND ,
153 0xd000fce1; since Linux 2.5.18).
154 The system is suspended (hibernated) to disk.
155 This option is available only if the kernel was configured with
156 .BR CONFIG_HIBERNATION .
157 .LP
158 Only the superuser may call
159 .BR reboot ().
160 .LP
161 The precise effect of the above actions depends on the architecture.
162 For the i386 architecture, the additional argument does not do
163 anything at present (2.1.122), but the type of reboot can be
164 determined by kernel command-line arguments ("reboot=...") to be
165 either warm or cold, and either hard or through the BIOS.
166 .SS Behavior inside PID namespaces
167 .\" commit cf3f89214ef6a33fad60856bc5ffd7bb2fc4709b
168 .\" see also commit 923c7538236564c46ee80c253a416705321f13e3
169 Since Linux 3.4, when
170 .BR reboot ()
171 is called from a PID namespace (see
172 .BR pid_namespaces (7))
173 other than the initial PID namespace,
174 the effect of the call is to send a signal to the namespace "init" process.
175 .BR LINUX_REBOOT_CMD_RESTART
176 and
177 .BR LINUX_REBOOT_CMD_RESTART2
178 cause a
179 .BR SIGHUP
180 signal to be sent.
181 .BR LINUX_REBOOT_CMD_POWER_OFF
182 and
183 .BR LINUX_REBOOT_CMD_HALT
184 cause a
185 .B SIGINT
186 signal to be sent.
187 .SH RETURN VALUE
188 For the values of
189 .I cmd
190 that stop or restart the system,
191 a successful call to
192 .BR reboot ()
193 does not return.
194 For the other
195 .I cmd
196 values, zero is returned on success.
197 In all cases, \-1 is returned on failure, and
198 .I errno
199 is set appropriately.
200 .SH ERRORS
201 .TP
202 .B EFAULT
203 Problem with getting user-space data under
204 .BR LINUX_REBOOT_CMD_RESTART2 .
205 .TP
206 .B EINVAL
207 Bad magic numbers or \fIcmd\fP.
208 .TP
209 .B EPERM
210 The calling process has insufficient privilege to call
211 .BR reboot ();
212 the
213 .B CAP_SYS_BOOT
214 capability is required.
215 .SH CONFORMING TO
216 .BR reboot ()
217 is Linux-specific,
218 and should not be used in programs intended to be portable.
219 .SH SEE ALSO
220 .BR kexec_load (2),
221 .BR sync (2),
222 .BR bootparam (7),
223 .BR capabilities (7),
224 .BR ctrlaltdel (8),
225 .BR halt (8),
226 .BR reboot (8)
227 .SH COLOPHON
228 This page is part of release 3.79 of the Linux
229 .I man-pages
230 project.
231 A description of the project,
232 information about reporting bugs,
233 and the latest version of this page,
234 can be found at
235 \%http://www.kernel.org/doc/man\-pages/.