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