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