]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/reboot.2
accept.2: Simplify the discussion of 'socklen_t'
[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.\"
b8efb414 28.TH REBOOT 2 2016-10-08 "Linux" "Linux Programmer's Manual"
fea681da
MK
29.SH NAME
30reboot \- reboot or enable/disable Ctrl-Alt-Del
31.SH SYNOPSIS
e81aee2d
MK
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: */
fea681da
MK
36.sp
37.B #include <unistd.h>
38.br
39.B #include <linux/reboot.h>
40.sp
350d584d 41.BI "int reboot(int " magic ", int " magic2 ", int " cmd ", void *" arg );
fea681da 42.sp
25fe5693
CTV
43/* Under glibc and most alternative libc's (including uclibc, dietlibc,
44 musl and a few others), some of the constants involved have gotten
e81aee2d
MK
45 symbolic names RB_*, and the library call is a 1-argument
46 wrapper around the 3-argument system call: */
fea681da
MK
47.sp
48.B #include <unistd.h>
49.br
50.B #include <sys/reboot.h>
51.sp
350d584d 52.BI "int reboot(int " cmd );
fea681da 53.SH DESCRIPTION
c13182ef 54The
e511ffb6 55.BR reboot ()
fea681da
MK
56call reboots the system, or enables/disables the reboot keystroke
57(abbreviated CAD, since the default is Ctrl-Alt-Delete;
58it can be changed using
59.BR loadkeys (1)).
60.PP
682edefb
MK
61This system call will fail (with
62.BR EINVAL )
63unless
fea681da 64.I magic
682edefb 65equals
0daa9e92 66.B LINUX_REBOOT_MAGIC1
682edefb 67(that is, 0xfee1dead) and
fea681da 68.I magic2
682edefb 69equals
0daa9e92 70.B LINUX_REBOOT_MAGIC2
682edefb
MK
71(that is, 672274793).
72However, since 2.1.17 also
0daa9e92 73.B LINUX_REBOOT_MAGIC2A
682edefb
MK
74(that is, 85072278)
75and since 2.1.97 also
0daa9e92 76.B LINUX_REBOOT_MAGIC2B
682edefb
MK
77(that is, 369367448)
78and since 2.5.71 also
0daa9e92 79.B LINUX_REBOOT_MAGIC2C
682edefb 80(that is, 537993216)
2b91ac79 81are permitted as values for
fea681da
MK
82.IR magic2 .
83(The hexadecimal values of these constants are meaningful.)
352e737d 84
fea681da 85The
350d584d 86.I cmd
fea681da
MK
87argument can have the following values:
88.TP
939fd8db 89.B LINUX_REBOOT_CMD_CAD_OFF
4cead6db
MK
90.RB ( RB_DISABLE_CAD ,
910).
939fd8db
MK
92CAD is disabled.
93This means that the CAD keystroke will cause a
94.B SIGINT
95signal to be
96sent to init (process 1), whereupon this process may decide upon a
97proper action (maybe: kill all processes, sync, reboot).
98.TP
99.B LINUX_REBOOT_CMD_CAD_ON
4cead6db
MK
100.RB ( RB_ENABLE_CAD ,
1010x89abcdef).
939fd8db
MK
102CAD is enabled.
103This means that the CAD keystroke will immediately cause
104the action associated with
105.BR LINUX_REBOOT_CMD_RESTART .
fea681da
MK
106.TP
107.B LINUX_REBOOT_CMD_HALT
4cead6db
MK
108.RB ( RB_HALT_SYSTEM ,
1090xcdef0123; since Linux 1.1.76).
2d986c92 110The message "System halted." is printed, and the system is halted.
fea681da
MK
111Control is given to the ROM monitor, if there is one.
112If not preceded by a
113.BR sync (2),
114data will be lost.
115.TP
d1d5d51c 116.BR LINUX_REBOOT_CMD_KEXEC
4cead6db 117.RB ( RB_KEXEC ,
fd00f12c 1180x45584543, since Linux 2.6.13).
939fd8db
MK
119Execute a kernel that has been loaded earlier with
120.BR kexec_load (2).
33a0ccb2 121This option is available only if the kernel was configured with
939fd8db
MK
122.BR CONFIG_KEXEC .
123.TP
fea681da 124.B LINUX_REBOOT_CMD_POWER_OFF
4cead6db
MK
125.RB ( RB_POWER_OFF ,
1260x4321fedc; since Linux 2.1.30).
2d986c92 127The message "Power down." is printed, the system is stopped,
fea681da
MK
128and all power is removed from the system, if possible.
129If not preceded by a
130.BR sync (2),
131data will be lost.
132.TP
939fd8db 133.B LINUX_REBOOT_CMD_RESTART
4cead6db
MK
134.RB ( RB_AUTOBOOT ,
1350x1234567).
939fd8db
MK
136The message "Restarting system." is printed, and a default
137restart is performed immediately.
138If not preceded by a
139.BR sync (2),
140data will be lost.
141.TP
fea681da 142.B LINUX_REBOOT_CMD_RESTART2
0b23bb07 143(0xa1b2c3d4; since Linux 2.1.30).
9708eb37 144The message "Restarting system with command \(aq%s\(aq" is printed,
fea681da
MK
145and a restart (using the command string given in
146.IR arg )
147is performed immediately.
148If not preceded by a
149.BR sync (2),
150data will be lost.
2d37a960 151.TP
d3532647 152.BR LINUX_REBOOT_CMD_SW_SUSPEND
4cead6db
MK
153.RB ( RB_SW_SUSPEND ,
1540xd000fce1; since Linux 2.5.18).
2d37a960
EDB
155The system is suspended (hibernated) to disk.
156This option is available only if the kernel was configured with
157.BR CONFIG_HIBERNATION .
fea681da 158.LP
350d584d
MK
159Only the superuser may call
160.BR reboot ().
fea681da
MK
161.LP
162The precise effect of the above actions depends on the architecture.
163For the i386 architecture, the additional argument does not do
164anything at present (2.1.122), but the type of reboot can be
84c517a4 165determined by kernel command-line arguments ("reboot=...") to be
fea681da 166either warm or cold, and either hard or through the BIOS.
50f31881 167.SS Behavior inside PID namespaces
29368ba0
MK
168.\" commit cf3f89214ef6a33fad60856bc5ffd7bb2fc4709b
169.\" see also commit 923c7538236564c46ee80c253a416705321f13e3
170Since Linux 3.4, when
50f31881
MK
171.BR reboot ()
172is called from a PID namespace (see
173.BR pid_namespaces (7))
174other than the initial PID namespace,
175the effect of the call is to send a signal to the namespace "init" process.
5ddb62b2 176The
50f31881
MK
177.BR LINUX_REBOOT_CMD_RESTART
178and
179.BR LINUX_REBOOT_CMD_RESTART2
5ddb62b2
MK
180.I cmd
181values cause a
50f31881
MK
182.BR SIGHUP
183signal to be sent.
5ddb62b2 184The
50f31881
MK
185.BR LINUX_REBOOT_CMD_POWER_OFF
186and
187.BR LINUX_REBOOT_CMD_HALT
5ddb62b2
MK
188.I cmd
189values cause a
50f31881
MK
190.B SIGINT
191signal to be sent.
90e072b6
WL
192For the other
193.I cmd
194values, \-1 is returned and
195.I errno
196is set to
197.BR EINVAL .
47297adb 198.SH RETURN VALUE
350d584d
MK
199For the values of
200.I cmd
201that stop or restart the system,
202a successful call to
203.BR reboot ()
204does not return.
205For the other
206.I cmd
207values, zero is returned on success.
208In all cases, \-1 is returned on failure, and
fea681da
MK
209.I errno
210is set appropriately.
211.SH ERRORS
212.TP
213.B EFAULT
7fac88a9 214Problem with getting user-space data under
682edefb 215.BR LINUX_REBOOT_CMD_RESTART2 .
fea681da
MK
216.TP
217.B EINVAL
350d584d 218Bad magic numbers or \fIcmd\fP.
fea681da
MK
219.TP
220.B EPERM
c13182ef 221The calling process has insufficient privilege to call
e511ffb6 222.BR reboot ();
a0b4ac2c 223the caller must have the
fea681da 224.B CAP_SYS_BOOT
a0b4ac2c 225inside its user namespace.
47297adb 226.SH CONFORMING TO
e511ffb6 227.BR reboot ()
8382f16d 228is Linux-specific,
97c1eac8 229and should not be used in programs intended to be portable.
47297adb 230.SH SEE ALSO
260be1fe 231.BR kexec_load (2),
fea681da
MK
232.BR sync (2),
233.BR bootparam (7),
234.BR capabilities (7),
235.BR ctrlaltdel (8),
236.BR halt (8),
237.BR reboot (8)