Debian Codegraph @

upstream/debian-unstable/man2/reboot.2

raw
1 .\" Copyright 1998, Andries E. Brouwer <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH reboot 2 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 reboot \- reboot or enable/disable Ctrl-Alt-Del
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ,\~ \-lc )
12 .SH SYNOPSIS
13 .nf
14 .RB "/* Since Linux 2.1.30 there are symbolic names " LINUX_REBOOT_*
15 for the constants and a fourth argument to the call: */
16 .P
17 .BR "#include <linux/reboot.h> " \
18 "/* Definition of " LINUX_REBOOT_* " constants */"
19 .BR "#include <sys/syscall.h> " "/* Definition of " SYS_* " constants */"
20 .B #include <unistd.h>
21 .P
22 .BI "int syscall(SYS_reboot, int " magic ", int " magic2 ", int " op ", void *" arg );
23 .P
24 /* Under glibc and most alternative libc's (including uclibc, dietlibc,
25 musl and a few others), some of the constants involved have gotten
26 .RB " symbolic names " RB_* ", and the library call is a 1-argument"
27 wrapper around the system call: */
28 .P
29 .BR "#include <sys/reboot.h> " "/* Definition of " RB_* " constants */"
30 .B #include <unistd.h>
31 .P
32 .BI "int reboot(int " op );
33 .fi
34 .SH DESCRIPTION
35 The
36 .BR reboot ()
37 call reboots the system, or enables/disables the reboot keystroke
38 (abbreviated CAD, since the default is Ctrl-Alt-Delete;
39 it can be changed using
40 .BR loadkeys (1)).
41 .P
42 This system call fails (with the error
43 .BR EINVAL )
44 unless
45 .I magic
46 equals
47 .B LINUX_REBOOT_MAGIC1
48 (that is, 0xfee1dead) and
49 .I magic2
50 equals
51 .B LINUX_REBOOT_MAGIC2
52 (that is, 0x28121969).
53 However, since Linux 2.1.17 also
54 .B LINUX_REBOOT_MAGIC2A
55 (that is, 0x05121996)
56 and since Linux 2.1.97 also
57 .B LINUX_REBOOT_MAGIC2B
58 (that is, 0x16041998)
59 and since Linux 2.5.71 also
60 .B LINUX_REBOOT_MAGIC2C
61 (that is, 0x20112000)
62 are permitted as values for
63 .IR magic2 .
64 (The hexadecimal values of these constants are meaningful.)
65 .P
66 The
67 .I op
68 argument can have the following values:
69 .TP
70 .B LINUX_REBOOT_CMD_CAD_OFF
71 .RB ( RB_DISABLE_CAD ,
72 0).
73 CAD is disabled.
74 This means that the CAD keystroke will cause a
75 .B SIGINT
76 signal to be
77 sent to init (process 1), whereupon this process may decide upon a
78 proper action (maybe: kill all processes, sync, reboot).
79 .TP
80 .B LINUX_REBOOT_CMD_CAD_ON
81 .RB ( RB_ENABLE_CAD ,
82 0x89abcdef).
83 CAD is enabled.
84 This means that the CAD keystroke will immediately cause
85 the action associated with
86 .BR LINUX_REBOOT_CMD_RESTART .
87 .TP
88 .B LINUX_REBOOT_CMD_HALT
89 .RB ( RB_HALT_SYSTEM ,
90 0xcdef0123;
91 since Linux 1.1.76).
92 The message "System halted." is printed, and the system is halted.
93 Control is given to the ROM monitor, if there is one.
94 If not preceded by a
95 .BR sync (2),
96 data will be lost.
97 .TP
98 .B LINUX_REBOOT_CMD_KEXEC
99 .RB ( RB_KEXEC ,
100 0x45584543, since Linux 2.6.13).
101 Execute a kernel that has been loaded earlier with
102 .BR kexec_load (2).
103 This option is available only if the kernel was configured with
104 .BR CONFIG_KEXEC .
105 .TP
106 .B LINUX_REBOOT_CMD_POWER_OFF
107 .RB ( RB_POWER_OFF ,
108 0x4321fedc;
109 since Linux 2.1.30).
110 The message "Power down." is printed, the system is stopped,
111 and all power is removed from the system, if possible.
112 If not preceded by a
113 .BR sync (2),
114 data will be lost.
115 .TP
116 .B LINUX_REBOOT_CMD_RESTART
117 .RB ( RB_AUTOBOOT ,
118 0x1234567).
119 The message "Restarting system." is printed, and a default
120 restart is performed immediately.
121 If not preceded by a
122 .BR sync (2),
123 data will be lost.
124 .TP
125 .B LINUX_REBOOT_CMD_RESTART2
126 (0xa1b2c3d4;
127 since Linux 2.1.30).
128 The message "Restarting system with command \[aq]%s\[aq]" is printed,
129 and a restart (using the command string given in
130 .IR arg )
131 is performed immediately.
132 If not preceded by a
133 .BR sync (2),
134 data will be lost.
135 .TP
136 .B LINUX_REBOOT_CMD_SW_SUSPEND
137 .RB ( RB_SW_SUSPEND ,
138 0xd000fce1;
139 since Linux 2.5.18).
140 The system is suspended (hibernated) to disk.
141 This option is available only if the kernel was configured with
142 .BR CONFIG_HIBERNATION .
143 .P
144 Only the superuser may call
145 .BR reboot ().
146 .P
147 The precise effect of the above actions depends on the architecture.
148 For the i386 architecture, the additional argument does not do
149 anything at present (2.1.122), but the type of reboot can be
150 determined by kernel command-line arguments ("reboot=...") to be
151 either warm or cold, and either hard or through the BIOS.
152 .\"
153 .SS Behavior inside PID namespaces
154 .\" commit cf3f89214ef6a33fad60856bc5ffd7bb2fc4709b
155 .\" see also commit 923c7538236564c46ee80c253a416705321f13e3
156 Since Linux 3.4,
157 if
158 .BR reboot ()
159 is called
160 from a PID namespace other than the initial PID namespace
161 with one of the
162 .I op
163 values listed below,
164 it performs a "reboot" of that namespace:
165 the "init" process of the PID namespace is immediately terminated,
166 with the effects described in
167 .BR pid_namespaces (7).
168 .P
169 The values that can be supplied in
170 .I op
171 when calling
172 .BR reboot ()
173 in this case are as follows:
174 .TP
175 .B LINUX_REBOOT_CMD_RESTART
176 .TQ
177 .B LINUX_REBOOT_CMD_RESTART2
178 The "init" process is terminated,
179 and
180 .BR wait (2)
181 in the parent process reports that the child was killed with a
182 .B SIGHUP
183 signal.
184 .TP
185 .B LINUX_REBOOT_CMD_POWER_OFF
186 .TQ
187 .B LINUX_REBOOT_CMD_HALT
188 The "init" process is terminated,
189 and
190 .BR wait (2)
191 in the parent process reports that the child was killed with a
192 .B SIGINT
193 signal.
194 .P
195 For the other
196 .I op
197 values,
198 .BR reboot ()
199 returns \-1 and
200 .I errno
201 is set to
202 .BR EINVAL .
203 .SH RETURN VALUE
204 For the values of
205 .I op
206 that stop or restart the system,
207 a successful call to
208 .BR reboot ()
209 does not return.
210 For the other
211 .I op
212 values, zero is returned on success.
213 In all cases, \-1 is returned on failure, and
214 .I errno
215 is set to indicate the error.
216 .SH ERRORS
217 .TP
218 .B EFAULT
219 Problem with getting user-space data under
220 .BR LINUX_REBOOT_CMD_RESTART2 .
221 .TP
222 .B EINVAL
223 Bad magic numbers or
224 .IR op .
225 .TP
226 .B EPERM
227 The calling process has insufficient privilege to call
228 .BR reboot ();
229 the caller must have the
230 .B CAP_SYS_BOOT
231 inside its user namespace.
232 .SH STANDARDS
233 Linux.
234 .SH SEE ALSO
235 .BR systemctl (1),
236 .BR systemd (1),
237 .BR kexec_load (2),
238 .BR sync (2),
239 .BR bootparam (7),
240 .BR capabilities (7),
241 .BR ctrlaltdel (8),
242 .BR halt (8),
243 .BR shutdown (8)