]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/reboot.2
Format errno.
[thirdparty/man-pages.git] / man2 / reboot.2
CommitLineData
fea681da
MK
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.
c13182ef 11.\"
fea681da
MK
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.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
305a0578 22.\" Modified, 27 May 2004, Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
23.\" Added notes on capability requirements
24.\"
d9343c5c 25.TH REBOOT 2 2004-05-27 "Linux" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27reboot \- reboot or enable/disable Ctrl-Alt-Del
28.SH SYNOPSIS
29For libc4 and libc5 the library call and the system call are identical,
30and since kernel version 2.1.30 there are symbolic names
31LINUX_REBOOT_* for the constants and a fourth argument to the call:
32.sp
33.B #include <unistd.h>
34.br
35.B #include <linux/reboot.h>
36.sp
37.BI "int reboot(int " magic ", int " magic2 ", int " flag ", void *" arg );
38.sp
39Under glibc some of the constants involved have gotten symbolic names RB_*,
40and the library call is a 1-argument wrapper around the 3-argument
41system call:
42.sp
43.B #include <unistd.h>
44.br
45.B #include <sys/reboot.h>
46.sp
47.BI "int reboot(int " flag );
48.SH DESCRIPTION
c13182ef 49The
e511ffb6 50.BR reboot ()
fea681da
MK
51call reboots the system, or enables/disables the reboot keystroke
52(abbreviated CAD, since the default is Ctrl-Alt-Delete;
53it can be changed using
54.BR loadkeys (1)).
55.PP
56This system call will fail (with EINVAL) unless
57.I magic
58equals LINUX_REBOOT_MAGIC1 (that is, 0xfee1dead) and
59.I magic2
60equals LINUX_REBOOT_MAGIC2 (that is, 672274793).
61However, since 2.1.17 also LINUX_REBOOT_MAGIC2A (that is, 85072278)
62and since 2.1.97 also LINUX_REBOOT_MAGIC2B (that is, 369367448)
63and since 2.5.71 also LINUX_REBOOT_MAGIC2C (that is, 537993216)
64are permitted as value for
65.IR magic2 .
66(The hexadecimal values of these constants are meaningful.)
67The
68.I flag
69argument can have the following values:
70.TP
71.B LINUX_REBOOT_CMD_RESTART
72(RB_AUTOBOOT, 0x1234567).
73The message `Restarting system.' is printed, and a default
74restart is performed immediately.
75If not preceded by a
76.BR sync (2),
77data will be lost.
78.TP
79.B LINUX_REBOOT_CMD_HALT
80(RB_HALT_SYSTEM, 0xcdef0123; since 1.1.76).
81The message `System halted.' is printed, and the system is halted.
82Control is given to the ROM monitor, if there is one.
83If not preceded by a
84.BR sync (2),
85data will be lost.
86.TP
87.B LINUX_REBOOT_CMD_POWER_OFF
88(0x4321fedc; since 2.1.30).
89The message `Power down.' is printed, the system is stopped,
90and all power is removed from the system, if possible.
91If not preceded by a
92.BR sync (2),
93data will be lost.
94.TP
95.B LINUX_REBOOT_CMD_RESTART2
96(0xa1b2c3d4; since 2.1.30).
97The message `Restarting system with command '%s'' is printed,
98and a restart (using the command string given in
99.IR arg )
100is performed immediately.
101If not preceded by a
102.BR sync (2),
103data will be lost.
104.TP
105.B LINUX_REBOOT_CMD_CAD_ON
106(RB_ENABLE_CAD, 0x89abcdef).
107CAD is enabled.
108This means that the CAD keystroke will immediately cause
99d2b7a2 109the action associated with LINUX_REBOOT_CMD_RESTART.
fea681da
MK
110.TP
111.B LINUX_REBOOT_CMD_CAD_OFF
112(RB_DISABLE_CAD, 0).
113CAD is disabled.
8bd58774
MK
114This means that the CAD keystroke will cause a
115.B SIGINT
116signal to be
fea681da
MK
117sent to init (process 1), whereupon this process may decide upon a
118proper action (maybe: kill all processes, sync, reboot).
119.LP
2c8d1c7d 120Only the superuser may use this function.
fea681da
MK
121.LP
122The precise effect of the above actions depends on the architecture.
123For the i386 architecture, the additional argument does not do
124anything at present (2.1.122), but the type of reboot can be
125determined by kernel command line arguments (`reboot=...') to be
126either warm or cold, and either hard or through the BIOS.
127.SH "RETURN VALUE"
c13182ef
MK
128On success, zero is returned.
129On error, \-1 is returned, and
fea681da
MK
130.I errno
131is set appropriately.
132.SH ERRORS
133.TP
134.B EFAULT
135Problem with getting userspace data under LINUX_REBOOT_CMD_RESTART2.
136.TP
137.B EINVAL
138Bad magic numbers or \fIflag\fP.
139.TP
140.B EPERM
c13182ef 141The calling process has insufficient privilege to call
e511ffb6 142.BR reboot ();
fea681da
MK
143the
144.B CAP_SYS_BOOT
145capability is required.
146.SH "CONFORMING TO"
e511ffb6 147.BR reboot ()
c13182ef 148is Linux specific,
97c1eac8 149and should not be used in programs intended to be portable.
fea681da
MK
150.SH "SEE ALSO"
151.BR sync (2),
152.BR bootparam (7),
153.BR capabilities (7),
154.BR ctrlaltdel (8),
155.BR halt (8),
156.BR reboot (8)