OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[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 2010-10-31 "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 value for
81 .IR magic2 .
82 (The hexadecimal values of these constants are meaningful.)
83 The
84 .I cmd
85 argument can have the following values:
86 .TP
87 .B LINUX_REBOOT_CMD_CAD_OFF
88 (RB_DISABLE_CAD, 0).
89 CAD is disabled.
90 This means that the CAD keystroke will cause a
91 .B SIGINT
92 signal to be
93 sent to init (process 1), whereupon this process may decide upon a
94 proper action (maybe: kill all processes, sync, reboot).
95 .TP
96 .B LINUX_REBOOT_CMD_CAD_ON
97 (RB_ENABLE_CAD, 0x89abcdef).
98 CAD is enabled.
99 This means that the CAD keystroke will immediately cause
100 the action associated with
101 .BR LINUX_REBOOT_CMD_RESTART .
102 .TP
103 .B LINUX_REBOOT_CMD_HALT
104 (RB_HALT_SYSTEM, 0xcdef0123; since 1.1.76).
105 The message "System halted." is printed, and the system is halted.
106 Control is given to the ROM monitor, if there is one.
107 If not preceded by a
108 .BR sync (2),
109 data will be lost.
110 .TP
111 .BR LINUX_REBOOT_CMD_KEXEC " (since Linux 2.6.13)"
112 Execute a kernel that has been loaded earlier with
113 .BR kexec_load (2).
114 This option is only available if the kernel was configured with
115 .BR CONFIG_KEXEC .
116 .TP
117 .B LINUX_REBOOT_CMD_POWER_OFF
118 (0x4321fedc; since 2.1.30).
119 The message "Power down." is printed, the system is stopped,
120 and all power is removed from the system, if possible.
121 If not preceded by a
122 .BR sync (2),
123 data will be lost.
124 .TP
125 .B LINUX_REBOOT_CMD_RESTART
126 (RB_AUTOBOOT, 0x1234567).
127 The message "Restarting system." is printed, and a default
128 restart is performed immediately.
129 If not preceded by a
130 .BR sync (2),
131 data will be lost.
132 .TP
133 .B LINUX_REBOOT_CMD_RESTART2
134 (0xa1b2c3d4; since 2.1.30).
135 The message "Restarting system with command \(aq%s\(aq" is printed,
136 and a restart (using the command string given in
137 .IR arg )
138 is performed immediately.
139 If not preceded by a
140 .BR sync (2),
141 data will be lost.
142 .LP
143 Only the superuser may call
144 .BR reboot ().
145 .LP
146 The precise effect of the above actions depends on the architecture.
147 For the i386 architecture, the additional argument does not do
148 anything at present (2.1.122), but the type of reboot can be
149 determined by kernel command-line arguments ("reboot=...") to be
150 either warm or cold, and either hard or through the BIOS.
151 .SH RETURN VALUE
152 For the values of
153 .I cmd
154 that stop or restart the system,
155 a successful call to
156 .BR reboot ()
157 does not return.
158 For the other
159 .I cmd
160 values, zero is returned on success.
161 In all cases, \-1 is returned on failure, and
162 .I errno
163 is set appropriately.
164 .SH ERRORS
165 .TP
166 .B EFAULT
167 Problem with getting user-space data under
168 .BR LINUX_REBOOT_CMD_RESTART2 .
169 .TP
170 .B EINVAL
171 Bad magic numbers or \fIcmd\fP.
172 .TP
173 .B EPERM
174 The calling process has insufficient privilege to call
175 .BR reboot ();
176 the
177 .B CAP_SYS_BOOT
178 capability is required.
179 .SH CONFORMING TO
180 .BR reboot ()
181 is Linux-specific,
182 and should not be used in programs intended to be portable.
183 .SH SEE ALSO
184 .BR sync (2),
185 .BR bootparam (7),
186 .BR capabilities (7),
187 .BR ctrlaltdel (8),
188 .BR halt (8),
189 .BR reboot (8)