OSDN Git Service

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